C# System.Web.Routing.UrlRoutingModule未实现IHttpHandlerFactory或IHttpHandler

C# System.Web.Routing.UrlRoutingModule未实现IHttpHandlerFactory或IHttpHandler,c#,asp.net-mvc,iis,amazon,nopcommerce,C#,Asp.net Mvc,Iis,Amazon,Nopcommerce,在我们的网站上,此错误每5分钟出现一次。 我也不知道从哪里传来的。 有人能帮我们吗。 我们需要没有这个错误的robots.txt 我们的应用程序是自动呼叫 并显示以下异常 System.Web.Routing.UrlRoutingModule未实现 IHttpHandler工厂或IHttpHandler 描述:在执行过程中发生未处理的异常 当前的web请求。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源 这是调用此方法时自动生成robots.txt文件的方法。但问题在于应用程序中

在我们的网站上,此错误每5分钟出现一次。 我也不知道从哪里传来的。 有人能帮我们吗。 我们需要没有这个错误的robots.txt

我们的应用程序是自动呼叫 并显示以下异常

System.Web.Routing.UrlRoutingModule未实现 IHttpHandler工厂或IHttpHandler

描述:在执行过程中发生未处理的异常 当前的web请求。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源

这是调用此方法时自动生成robots.txt文件的方法。但问题在于应用程序中的robots.txt会自动调用

  public ActionResult RobotsTextFile()
            {
                //Default Code blocked by Nilesh
                if (_storeContext.CurrentStore.Url.Contains("tk"))
                {
                    const string newLine = "\r\n"; //Environment.NewLine
                    var sb = new StringBuilder();
                    sb.Append("User-agent: *");
                    sb.Append(newLine);
                    sb.Append("Disallow: /");
                    Response.ContentType = "text/plain";
                    Response.Write(sb.ToString());
                }
                else
                {
                    var disallowPaths = new List<string>
                                        {
                                            "/bin/",
                                            "/content/files/",
                                            "/content/files/exportimport/",
                                            "/country/getstatesbycountryid",
                                            "/install",
                                            "/setproductreviewhelpfulness",
                                        };
                    var localizableDisallowPaths = new List<string>
                                                   {
                                                       "/addproducttocart/catalog/",
                                                       "/addproducttocart/details/",
                                                       "/backinstocksubscriptions/manage",
                                                       "/boards/forumsubscriptions",
                                                       "/boards/forumwatch",
                                                       "/boards/postedit",
                                                       "/boards/postdelete",
                                                       "/boards/postcreate",
                                                       "/boards/topicedit",
                                                       "/boards/topicdelete",
                                                       "/boards/topiccreate",
                                                       "/boards/topicmove",
                                                       "/boards/topicwatch",
                                                       "/cart",
                                                       "/checkout",
                                                       "/checkout/billingaddress",
                                                       "/checkout/completed",
                                                       "/checkout/confirm",
                                                       "/checkout/shippingaddress",
                                                       "/checkout/shippingmethod",
                                                       "/checkout/paymentinfo",
                                                       "/checkout/paymentmethod",
                                                       "/clearcomparelist",
                                                       "/compareproducts",
                                                       "/customer/avatar",
                                                       "/customer/activation",
                                                       "/customer/addresses",
                                                       "/customer/changepassword",
                                                       "/customer/checkusernameavailability",
                                                       "/customer/downloadableproducts",
                                                       "/customer/info",
                                                       "/deletepm",
                                                       "/emailwishlist",
                                                       "/inboxupdate",
                                                       "/newsletter/subscriptionactivation",
                                                       "/onepagecheckout",
                                                       "/order/history",
                                                       "/orderdetails",
                                                       "/passwordrecovery/confirm",
                                                       "/poll/vote",
                                                       "/privatemessages",
                                                       "/returnrequest",
                                                       "/returnrequest/history",
                                                       "/rewardpoints/history",
                                                       "/sendpm",
                                                       "/sentupdate",
                                                       "/shoppingcart/productdetails_attributechange",
                                                       "/subscribenewsletter",
                                                       "/topic/authenticate",
                                                       "/viewpm",
                                                       "/uploadfileproductattribute",
                                                       "/uploadfilecheckoutattribute",
                                                       "/wishlist",
                                                   };


                    const string newLine = "\r\n"; //Environment.NewLine
                    var sb = new StringBuilder();
                    sb.Append("User-agent: *");
                    sb.Append(newLine);
                    //sitemaps
                    if (_localizationSettings.SeoFriendlyUrlsForLanguagesEnabled)
                    {
                        //URLs are localizable. Append SEO code
                        foreach (var language in _languageService.GetAllLanguages(storeId: _storeContext.CurrentStore.Id))
                        {
                            sb.AppendFormat("Sitemap: {0}{1}/sitemap.xml", _storeContext.CurrentStore.Url, language.UniqueSeoCode);
                            sb.Append(newLine);
                        }
                    }
                    else
                    {
                        //localizable paths (without SEO code)
                        sb.AppendFormat("Sitemap: {0}sitemap.xml", _storeContext.CurrentStore.Url);
                        sb.Append(newLine);
                    }

                    //usual paths
                    foreach (var path in disallowPaths)
                    {
                        sb.AppendFormat("Disallow: {0}", path);
                        sb.Append(newLine);
                    }
                    //localizable paths (without SEO code)
                    foreach (var path in localizableDisallowPaths)
                    {
                        sb.AppendFormat("Disallow: {0}", path);
                        sb.Append(newLine);
                    }
                    if (_localizationSettings.SeoFriendlyUrlsForLanguagesEnabled)
                    {
                        //URLs are localizable. Append SEO code
                        foreach (var language in _languageService.GetAllLanguages(storeId: _storeContext.CurrentStore.Id))
                        {
                            foreach (var path in localizableDisallowPaths)
                            {
                                sb.AppendFormat("Disallow: {0}{1}", language.UniqueSeoCode, path);
                                sb.Append(newLine);
                            }
                        }
                    }
                    Response.ContentType = "text/plain";
                    Response.Write(sb.ToString());
                }
                return null;
            }
每5分钟一次。我们使用amazon服务器进行CDN,从那里获取图像

是否有可能amazon将此url命名为“”

从web.config中删除(或注释掉)这一行以生成
robot.txt

<add name="RobotsTxt" path="robots.txt" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />

并取消对以下行的注释

<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />


希望这有帮助

最近发布了一个Web API,我最近更改了程序集名称,之后我遇到了同样的问题。我没有robots.txt文件,因此上述答案与我无关。无论如何,作为一个解决方案,我只是清理了服务器上的文件夹并重新发布。

我在服务器2016的新部署中也遇到了这个问题。最后,我实际上注释掉了URLRoutingModule的处理程序映射,它成功了。我的猜测是,它与机器级别上已经设置的内容相冲突

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
        <handlers>
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <remove name="OPTIONSVerbHandler" />
            <remove name="TRACEVerbHandler" />
            <!--<remove name="UrlRoutingModule-4.0"/>
            <add name="UrlRoutingModule-4.0" path="*" verb="*" type="System.Web.Routing.UrlRoutingModule" preCondition=""/>-->
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
    </system.webServer>


但是我们需要robots.txt文件,我需要把那一行放在哪里…?很抱歉,先生,不工作…:(在web配置中取消对此行的注释..但仍然出现相同的错误。)
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
        <handlers>
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <remove name="OPTIONSVerbHandler" />
            <remove name="TRACEVerbHandler" />
            <!--<remove name="UrlRoutingModule-4.0"/>
            <add name="UrlRoutingModule-4.0" path="*" verb="*" type="System.Web.Routing.UrlRoutingModule" preCondition=""/>-->
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
    </system.webServer>