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

后端 未结 4 1133
我在风中等你
我在风中等你 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:02

    You could use the

      Request.Url.AbsoluteUri
    

    Then just check the string for the page name.

    Might not be the best way, but its a quick and easy way.

    I got that method from this page:

    How to get current page URL in MVC 3

    There is also another answer there that may be useful for you.

提交回复
热议问题