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

后端 未结 4 865
故里飘歌
故里飘歌 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条回答
  •  旧时难觅i
    2020-12-01 13:21

    I've also tested this code, and I could do something with it. But, I'm not sure if is this a good solution or not.

    For example, I need to detect the Contacts view located in Home directory. So I wrote:

    if (@Request.RawUrl == "/Home/Contacts")
    {
       // do something
    }
    

提交回复
热议问题