asp.net-mvc – Asp.net Web api异常仅在IIS部署之后:名为“HelpPage_Default
发布时间:2020-05-24 02:08:15 所属栏目:asp.Net 来源:互联网
导读:我已经阅读了 this的问题,并尝试了在那里提到的解决方案,但是我收到这个异常,只有当我将应用程序发布到远程服务器的IIS.在本地计算机的IIS中,应用程序正常工作.我不知道在该服务器上导致此异常的原因: Server Error in / Application.A route named HelpPage
|
我已经阅读了 this的问题,并尝试了在那里提到的解决方案,但是我收到这个异常,只有当我将应用程序发布到远程服务器的IIS.在本地计算机的IIS中,应用程序正常工作.我不知道在该服务器上导致此异常的原因: Server Error in '/' Application. A route named 'HelpPage_Default' is already in the route collection. Route names must be unique. Parameter name: name Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: A route named 'HelpPage_Default' is already in the route collection. Route names must be unique. Parameter name: name Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [ArgumentException: A route named 'HelpPage_Default' is already in the route collection. Route names must be unique. Parameter name: name] System.Web.Routing.RouteCollection.Add(String name,RouteBase item) +3713577 System.Web.Mvc.RouteCollectionExtensions.MapRoute(RouteCollection routes,String name,String url,Object defaults,Object constraints,String[] namespaces) +350 System.Web.Mvc.AreaRegistrationContext.MapRoute(String name,String[] namespaces) +95 XbimServer.Areas.HelpPage.HelpPageAreaRegistration.RegisterArea(AreaRegistrationContext context) +174 System.Web.Mvc.AreaRegistration.RegisterAllAreas(RouteCollection routes,IBuildManager buildManager,Object state) +323 BimServer.WebApiApplication.Application_Start() +23 [HttpException (0x80004005): A route named 'HelpPage_Default' is already in the route collection. Route names must be unique. Parameter name: name] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context,HttpApplication app) +12600317 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext,HttpContext context,MethodInfo[] handlers) +175 System.Web.HttpApplication.InitSpecial(HttpApplicationState state,MethodInfo[] handlers,IntPtr appContext,HttpContext context) +304 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext context) +404 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475 [HttpException (0x80004005): A route named 'HelpPage_Default' is already in the route collection. Route names must be unique. Parameter name: name] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12617364 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context) +12456981 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34212 这是我在Global.asax.cs中设置的: protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
我的RouteConfig.cs: public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "Home",action = "Index",id = UrlParameter.Optional }
);
}
和我的WebApiConfig.cs: config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",routeTemplate: "api/{controller}/{id}",defaults: new { id = RouteParameter.Optional }
);
我也对我的web.config文件进行了以下更改: <system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
解决方法我刚遇到同样的问题.我认为这个错误是因为我先前将另一个解决方案推送到我的网站,而且还有一些剩下的文件被阻止了.为了解决这个问题,我在Visual Studio发布到我的Azure站点时勾选了“删除目的地的其他文件”框.我会假设你可以手动删除任何旧的文件在服务器上发布之前.之后,网站运行良好,没有错误. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
推荐文章
站长推荐
- asp.net-mvc – 解耦Microsoft.AspNet.Identity.
- TeamCity – 在ASP.net网站上发布的问题
- asp.net-mvc – 当我使用Validator.TryValidateO
- asp.net-mvc – 可以在ASP.NET MVC中本地化URL /
- azure – 当用户存储在外部身份提供程序服务中时
- asp.net-core – .Net 5中的调试设置
- asp.net – 如何显示UTC时间作为本地时间在网页?
- ASP.NET System.Data.EntityClient连接字符串帮助
- asp.net-mvc-3 – AZURE ACS – Windows Live ID
- asp.net-mvc-4 – OAuth2和DotNetOpenAuth – 实
热点阅读
