Retrieve the current view name in ASP.NET MVC?

后端 未结 10 893
谎友^
谎友^ 2020-11-28 09:37

I have a partial view (control) that\'s used across several view pages, and I need to pass the name of the current view back to the controller - so if there\'s e.g. validati

10条回答
  •  旧时难觅i
    2020-11-28 10:24

    If you are looking for solution for asp.net core you can use:

    @System.IO.Path.GetFileNameWithoutExtension(ViewContext.View.Path)
    

    This will return the current view name.

提交回复
热议问题