简体   繁体   English

返回视图时如何刷新我的页面

[英]how to refresh my page when returning a view

I am redirecting to a page after there are changes on the page. 页面上有更改后,我将重定向到页面。 However, I can only see the changes after I actually reload the entire page. 但是,我只能在实际重新加载整个页面后才能看到更改。

I'm redirecting to this page like this: 我将这样重定向到此页面:

public ActionResult Details(string id)
{
    return View(Function(id));
}

Is there something I may be able to put in my parameter that could refresh the page? 我是否可以在参数中添加一些内容来刷新页面?

OK this is a common mistake that people make when dealing with ASP.NET MVC. 好的,这是人们在处理ASP.NET MVC时常犯的错误。 You don't want to return the View instead you just want to redirect properly. 您不想返回视图,而只是想正确地重定向。

public ActionResult Detail(string id) {
    // actual redirect
    return RedirectToAction("Function", new { id });
}

This will make sure your controller makes an actual redirect, and not just displaying the view. 这将确保您的控制器进行实际的重定向,而不仅仅是显示视图。 This also insures your routes / url are valid. 这也可以确保您的路线/网址有效。 Hope this helps :) 希望这可以帮助 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM