Refresh a page in MVC
You can use the following code in asp.net core
public IActionResult Index(){
return Redirect($"{Request.Path.ToString()}{Request.QueryString.Value.ToString()}");
}
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());
}
You can use location.href = location.href;
in Javascript code after calling a buttonclick
or after a action method call like.
$('#btnme').click(function () {
location.href = location.href;
}
Just Redirect to the Action you want to redirect to. It will refresh your page.
[HttpGet]
public ActionResult Request()
{
if (Session["type"] != null && Session["resulttype"] != null)
{
return View();
}
else
{
return RedirectToAction("Request");
}
}