MVC RedirectToAction is not working properly

孤者浪人 提交于 2019-12-11 17:45:19

问题


In one of my controllers, I do have a return that looks like this:

return RedirectToAction("AdministerFiles/ViewDataFiles?catid=14");

but when it renders the result to the browser the string becomes this one:

AdministerFiles/AdministerFiles/ViewDataFiles%3fcatid%3d14

how can I solve this ? thanks .


回答1:


You just need the action as the parameter (along with the route data):

return RedirectToAction("ViewDataFiles", new { catid = 14 });

If you want to specify the controller as well (it defaults to the current controller), then you can do it like this:

return RedirectToAction("ViewDataFiles", "AdministerFiles", new { catid = 14 });


来源:https://stackoverflow.com/questions/10976797/mvc-redirecttoaction-is-not-working-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!