CaptchaMVC图像路由无法使用我在MVC3中的当前路由 - 如何解决?

时间:2012-08-02 16:16:00

标签: asp.net-mvc-3 c#-4.0 routes

安装CaptchaMVC后,我导航到我要测试功能的页面 - 〜/ about。

对于图片localhost:51860/DefaultCaptcha/Generate?t=6d9ab0cefbb8496582b1db592eff66f,我看到链接断开。

我添加了routes.IgnoreRoute("DefaultCaptcha/{*pathInfo}");并尝试routes.IgnoreRoute("DefaultCaptcha/Generate");到我的路线顶部,但图片仍然没有出现,导航到图片网址会返回404找不到错误。

当我从Global.asax删除所有路由时,这样可以正常工作。

我认为这个模式与此路线相符:

routes.MapRoute(name: "WholeCountryCategoryResults1", url: "{categoryName}/{searchTerm}/", defaults: new { controller = "Results", action = "SearchWholeCountryCategory" });

其他路线无关紧要,因为规则按顺序执行,那么这里的问题是什么?

感谢。

1 个答案:

答案 0 :(得分:4)

对于那些可能遇到同样问题的人,只需设置一条到验证码提供商的控制器和操作的路径:

routes.MapRoute(name: "DefaultCaptchaRoute", url: "DefaultCaptcha/Generate", defaults: new { controller = "DefaultCaptcha", action = "Generate" });