MVC RedirectToAction无法正常工作 [英] MVC RedirectToAction is not working properly

查看:54
本文介绍了MVC RedirectToAction无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个控制器中,确实有一个类似这样的回报:

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

我该如何解决?谢谢.

推荐答案

您只需要将action作为参数(以及路径数据):

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 });

这篇关于MVC RedirectToAction无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆