简体   繁体   中英

MVC Redirect to another page

I have a controller which processes an uploaded file. In that controller, I return the user to a SharePoint list depending on the successful parsing of that file. I am able to enter a direct URL, but I am opening this page in a form so I need to change the window.top.location instead of just window.location . I tried doing this a few ways such as returning a JavaScript result, but I received some browser warning messages I'd like to avoid.

I ended up making a partial razor view which grabs a parameter from the query string in order to determine which list it should go to. The function works fine, but the page is seemingly inactive when I return it using:

return Redirect("~/Parsing/ParsingRedirector?List=MasterDealer");

My page exists in the folder, but I get an error stating "The resource cannot be found. " Any reason why that's happening? I admittedly don't have a full understanding of MVC or even close to it at this point.

尝试这个:

return RedirectToAction("ParsingRedirector", "Parsing", new { List = "MasterDealer"});

This may be of help: http://www.dotnet-tricks.com/Tutorial/mvc/4XDc110313-return-View()-vs-return-RedirectToAction()-vs-return-Redirect()-vs-return-RedirectToRoute().html

Keep in mind that, per that article, in the case of Redirect "you have to specify the full URL to redirect."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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