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.
Just Redirect to the Action you want to redirect to. It will refresh your page. @Indianprogrammer According to Object Oriented Programming concept=> If you will return the 'RedirectToAction' then your method execution completes. else 'RedirectToAction' will be used as a Method for Processing something.
Window location.reload() The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.
Write("<script type='text/javascript'> setTimeout('location. reload(true); ', timeout);</script>"); Put the above code in button click event or anywhere you want to force page refresh.
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());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With