asp mvc 404 当 +在网址中
我的 asp mvc 3 应用程序有问题。当我将 +
字符放入网址中时,我总是收到 404 错误。所有请求都是ajax get请求。
如果我发出此请求 Test/Details/+ 我得到 404: Test/Details/+
这是 fiddler 中的请求: GET /Test%2FDetails%2F% 2B?t=1318678807718 HTTP/1.1
这里是路由。
routes.MapRoute(
"PagingTwoTest", // Route name
"{controller}/{action}/{tag}/p{currentPage}/p{secCurrentPage}/{*term}", // URL with parameters
new { secCurrentPage = UrlParameter.Optional, term = UrlParameter.Optional }, // Parameter defaults
new { currentPage = "\\d+", secCurrentPage = "\\d+" }
);
routes.MapRoute(
"PagingTwo", // Route name
"{controller}/{action}/p{currentPage}/p{secCurrentPage}/{*term}", // URL with parameters
new { secCurrentPage = UrlParameter.Optional, term = UrlParameter.Optional }, // Parameter defaults
new { currentPage = "\\d+", secCurrentPage = "\\d+" }
);
routes.MapRoute(
"Paging", // Route name
"{controller}/{action}/p{currentPage}/{*term}", // URL with parameters
new { term = UrlParameter.Optional }, // Parameter defaults
new { currentPage = "\\d+" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"DefaultName", // Route name
"{controller}/{action}/{*id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
I have problem with asp mvc 3 application. When I put the +
character in a url I always get a 404 error. All requests are ajax get request.
If I make this request Test/Details/+ I get 404: Test/Details/+
This is request in fiddler: GET /Test%2FDetails%2F%2B?t=1318678807718 HTTP/1.1
Here are routes.
routes.MapRoute(
"PagingTwoTest", // Route name
"{controller}/{action}/{tag}/p{currentPage}/p{secCurrentPage}/{*term}", // URL with parameters
new { secCurrentPage = UrlParameter.Optional, term = UrlParameter.Optional }, // Parameter defaults
new { currentPage = "\\d+", secCurrentPage = "\\d+" }
);
routes.MapRoute(
"PagingTwo", // Route name
"{controller}/{action}/p{currentPage}/p{secCurrentPage}/{*term}", // URL with parameters
new { secCurrentPage = UrlParameter.Optional, term = UrlParameter.Optional }, // Parameter defaults
new { currentPage = "\\d+", secCurrentPage = "\\d+" }
);
routes.MapRoute(
"Paging", // Route name
"{controller}/{action}/p{currentPage}/{*term}", // URL with parameters
new { term = UrlParameter.Optional }, // Parameter defaults
new { currentPage = "\\d+" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"DefaultName", // Route name
"{controller}/{action}/{*id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在你的限制中,你没有考虑当有人输入一个字符串时你总是请求一个数字,所以我认为你可以尝试:
所以在你的 TestController 中你可以请求一个字符串:
在你的
Details.aspx
中你可以这样写:In your constraints you are not considering when someone enters a string you allways request a digit, so I think you can try with:
So in your TestController you can request a string:
And in your
Details.aspx
you can put something like this: