In .NET MVC, is there an easy way to check if I'm on the home page?

后端 未结 4 1141
我在风中等你
我在风中等你 2021-02-14 10:25

I need to take a particular action if a user logs in from the home page. In my LogOnModel, I have a hidden field:

@Html.Hidden(\"returnUrl\", Request.Url.Absolut         


        
4条回答
  •  终归单人心
    2021-02-14 11:13

    In any view, the following code returns the current controller name.

    @ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString()
    

    Is it easy enough? :)

提交回复
热议问题