CaptchaMVC映像路由不适用于我在MVC3中的当前路由-如何解决



安装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" });

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

谢谢。

对于那些可能遇到相同问题的人,只需设置一条到captcha提供商控制器的路由并执行操作:

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

以下是对我有效的方法。将其添加到web.config

 <location path="DefaultCaptcha/Generate">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>

最新更新