Search code examples
asp.net-mvcrefresh

Refresh a page in MVC


How to refresh the current page in MVC.

[HttpGet]
public ActionResult Request()
{
    if (Session["type"] != null  && Session["resulttype"] != null)
    {
        return View();
    }
    else
    {
        return null;
    }
}

I want to refresh my page in else part. That is when return null value.


Solution

  • You can use Request.UrlReferrer.ToString()

    [HttpGet]
    public ActionResult Request()
    {
    
        if (Session["type"] != null  && Session["resulttype"] != null)
            return View();
        else
            return Redirect(Request.UrlReferrer.ToString());
    }