How to get the current view name in asp.net MVC 3?

后端 未结 4 871
故里飘歌
故里飘歌 2020-12-01 12:46

How can I get the current view name regarding to current URL, in asp.net MVC 3 using Razor engine?

4条回答
  •  感情败类
    2020-12-01 13:27

    ASP.NET Core's equivalent:

    @ViewContext.ExecutingFilePath
    

    Output is like this:

    /Views/Shared/String.cshtml
    

    The rendering of a view may involve one or more files (e.g. _ViewStart, Layouts etc). This property contains the path of the file currently being rendered.

    ViewContext.ExecutingFilePath Property

提交回复
热议问题