安装后CaptchaMVC我导航到要测试功能的页面 - ~/about。
对于图像 localhost:51860/DefaultCaptcha/Generate?t=6d9ab0cefbb8496582b1db592eff66f
,我看到一个损坏的链接。
我添加了 routes.IgnoreRoute("DefaultCaptcha/{*pathInfo}");
并且还尝试了 routes.IgnoreRoute("DefaultCaptcha/Generate");
到顶部我的路线,但图像仍然没有出现,导航到图像 url 返回 404 未找到错误。
当我从 Global.asax 中删除所有路由时,一切正常。
我认为这个问题是这个模式匹配这个路由:
routes.MapRoute(name: "WholeCountryCategoryResults1", url: "{categoryName}/{searchTerm}/", defaults: new { controller = "Results", action = "SearchWholeCountryCategory" });
其余的路由应该无关紧要,因为规则是按顺序执行的,所以这里有什么问题?
谢谢。
最佳答案
对于那些可能遇到同样问题的人,只需设置一个到验证码提供者的 Controller 和操作的路由:
routes.MapRoute(name: "DefaultCaptchaRoute", url: "DefaultCaptcha/Generate", defaults: new { controller = "DefaultCaptcha", action = "Generate" });
关于asp.net-mvc-3 - CaptchaMVC 图像路由不适用于我在 MVC3 中的当前路由 - 如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11781670/