MVC RedirectToAction is not working properly

2019-08-19 02:09发布

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条回答
The star\"
2楼-- · 2019-08-19 02:33

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 });
查看更多
登录 后发表回答