RedirectToAction - 但我希望它转到 http://example.com/controller/action/id?
我想将 ASP.NET MVC 响应移至
http://example.com /emails/list/[电子邮件受保护]
使用 RedirectToAction("list", "emails", new { id = "< a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a9dbc6cbe9ccc4c8c0c587cac6c4">[电子邮件受保护]"}); 带您前往 http://example.com/emails/[电子邮件受保护]。
我究竟做错了什么?
谢谢,
罗布
I'd like to move an asp.net mvc response to
http://example.com/emails/list/[email protected]
Using RedirectToAction("list", "emails", new { id = "[email protected]"}); takes you to http://example.com/emails/[email protected].
What am I doing wrong?
Thanks,
Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
啊 - 因为默认路由需要'id',所以你在视图(html)和控制器中的参数必须称为id。
Ah - because the default route requires 'id', your parameters in the view (html) and the controller must be called id.
好像路由配置错误。 Global.asax.cs 中的 RegisterRoutes 方法应如下所示:
在“{controller}/{action}/{id}”行中,存在 {id} 意味着将被替换为值。
路由字符串中不存在的任何其他参数将被解码为 ?some_param=value
Seems like misconfigured routing. Your RegisterRoutes method in Global.asax.cs should look like this:
In line "{controller}/{action}/{id}" presence of {id} means that is going to be substituted by it's value.
Any other parameter that is not present in routing string would be decoded as ?some_param=value