MVC2 url 中的斜杠字符
我想在 MVC2 url 中使用加密字符串。我的应用程序中的典型 url 如下所示:
http://localhost:29558/Account/PasswordReset/ZKGeDMZikfIsnO8/MEs7SCBlI+MZo1Je8LM5dTEeCt3u91ARPUcavT5UXfVVRfyE
请注意,PasswordReset/ 之后的所有内容都是加密字符串。在示例中,加密字符串包含斜杠,这会导致 MVC 崩溃。
我尝试在 Global.asax.cs 中添加 MapRoute,如下所示:
routes.MapRoute(
"PasswordResetSpecialCase", // Route name
"Account/PasswordReset/*", // URL with parameters
new { controller = "Account", action = "PasswordReset" } // Parameter defaults
);
但 MVC2 仍然失败,因为加密的字符串包含斜杠字符。如果我删除斜杠,那么它会起作用,但显然这不好。 如何让 MVC2 将 PasswordReset 之后的所有内容视为纯数据? 谢谢。
I want to use encrypted strings in MVC2 urls. A typical url in my app looks like this:
http://localhost:29558/Account/PasswordReset/ZKGeDMZikfIsnO8/MEs7SCBlI+MZo1Je8LM5dTEeCt3u91ARPUcavT5UXfVVRfyE
Note that everything after PasswordReset/ is the encrypted string. In the example the encrypted string contains a slash, and this is causing MVC to crash.
I've tried adding a MapRoute in Global.asax.cs as follows:
routes.MapRoute(
"PasswordResetSpecialCase", // Route name
"Account/PasswordReset/*", // URL with parameters
new { controller = "Account", action = "PasswordReset" } // Parameter defaults
);
but MVC2 is still falling over because the encrypted string contains a slash char. If I remove the slash then it works, but obviously that's no good.
How do I get MVC2 to regard everything after the PasswordReset as pure data?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的地图路线包含错误。将
*
替换为{*nameOfParameter}
Your maproute contains an error. Replace the
*
with{*nameOfParameter}