找不到.axd文件错误(http404) [英] .axd file not found error (http404)

查看:78
本文介绍了找不到.axd文件错误(http404)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个mvc4.5项目,我使用嵌入式id使用CaptchaHtmlHelper创建图像

配置文件如下所示

I am working on a mvc4.5 project where I am using the embedded id to create an image using the CaptchaHtmlHelper
the config file is as bellow

<system.web>
        <compilation targetFramework="4.5.1" />
        <customErrors mode="Off" defaultRedirect="Error"></customErrors>
        <httpRuntime targetFramework="4.5.1" />
        <httpHandlers>          
            <remove verb="*" path="*.asmx"/>
            <add verb="*" path="LanapCaptcha.axd" type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect" />
       </httpHandlers>  
 <handlers>
      <!-- Register the HttpHandler used for BotDetect Captcha 
      requests (IIS 7.0+) -->
      <remove name="LanapCaptchaHandler" />
      <add name="LanapCaptchaHandler" verb="*" path="LanapCaptcha.axd" type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect" />    
    </handlers>  



并且在我的Global.asax.cs文件中我将路线设置为


and in my Global.asax.cs file I have set the route as

public class MvcApplication : System.Web.HttpApplication
	{
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Login", action = "Index", id = UrlParameter.Optional }
            );
            
        }       

		protected void Application_Start()
		{
			AreaRegistration.RegisterAllAreas();
			FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
			//RouteConfig.RegisterRoutes(RouteTable.Routes);
			BundleConfig.RegisterBundles(BundleTable.Bundles);
		}



当我加载页面时出现以下错误


when I load the page I get the following error

Server Error in '/secure/account' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /secure/account/LanapCaptcha.axd

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408


如果您有任何人向我展示我必须做的事情,那么很高兴。

非常感谢


appreciate if you any one show me what I have to do.
thanks a lot

推荐答案

问题与mvc路由有关。我必须把路由放在下面

issue was with the mvc routing. I have to put the routing as bellow
routes.MapRoute(
              "RootPages_default",
              "RootPages/{controller}/{action}/{id}",
              new { controller = "Home", action = "Index", id = UrlParameter.Optional }
          );


< add verb =*path =LanapCaptcha.axdtype =Lanap。 BotDetect.CaptchaHandler,Lanap.BotDetect/>



您的错误路径是



请求的网址: /secure/account/LanapCaptcha.axd



它住在哪里?我认为你需要从\开始并指定axd文件的完整路径,如果它不在它的位置。如果它在那里,我想知道是否



routes.IgnoreRoute({resource} .axd / {* pathInfo});



导致问题。



您是否知道您可以直接在控制器中使用Route属性指定路由?
<add verb="*" path="LanapCaptcha.axd" type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect" />

Your error path is

Requested URL: /secure/account/LanapCaptcha.axd

Is that where it lives ? I think you need to start with a \ and specify the full path to the axd file, if that's not where it is. If it IS there, I'd wonder if

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

is causing issues.

Did you know you can specify routes using the Route attribute directly in the controller ?


这篇关于找不到.axd文件错误(http404)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆