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

Posted by Hairgami_Master on Stack Overflow See other posts from Stack Overflow or by Hairgami_Master
Published on 2012-06-27T18:32:58Z Indexed on 2012/06/27 21:16 UTC
Read the original article Hit count: 181

Filed under:
|
|

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.AbsoluteUri)

In my Controller, I need to check if that value is the Home page or not. In the example below, I'm checking to see if the user is on a particular page ("Account/ResetPassword"). Is there a way to check to see if they're on the home page without resorting to regular expressions?

    [HttpPost]
    public ActionResult LogOnInt(LogOnModel model)
    {
       if (model.returnUrl.Contains("/Account/ResetPassword"))
       {
          return Json(new { redirectToUrl = @Url.Action("Index","Home")});
       }

Any ideas? A million thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc