asp.net-mvc 在MVC中刷新页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22496898/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Refresh a page in MVC
提问by Jinesh
How to refresh the current page in MVC.
如何在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.
我想在其他部分刷新我的页面。那就是返回空值的时候。
回答by Jeyhun Rahimov
You can use Request.UrlReferrer.ToString()
您可以使用 Request.UrlReferrer.ToString()
[HttpGet]
public ActionResult Request()
{
if (Session["type"] != null && Session["resulttype"] != null)
return View();
else
return Redirect(Request.UrlReferrer.ToString());
}
回答by Rahul
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");
}
}
回答by Reza Jenabi
You can use the following code in asp.net core
你可以在asp.net core中使用以下代码
public IActionResult Index(){
return Redirect($"{Request.Path.ToString()}{Request.QueryString.Value.ToString()}");
}
回答by suraj gorad
You can use location.href = location.href;in Javascript code after calling a buttonclickor after a action method call like.
您可以location.href = location.href;在调用 abuttonclick或类似的操作方法调用之后在 Javascript 代码中使用。
$('#btnme').click(function () {
location.href = location.href;
}

