Refresh a page in MVC

Jinesh picture Jinesh · Mar 19, 2014 · Viewed 73.8k times · Source

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.

Answer

Jeyhun Rahimov picture Jeyhun Rahimov · Mar 19, 2014

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());
}