Problem:
A route named 'DefaultApi' 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 'DefaultApi' is already in the route collection. Route names must be unique.
Parameter name: name
Source Error:
Line 24: public static void Register(HttpConfiguration config)
Line 25: {
Line 26: config.Routes.MapHttpRoute(
Line 27: name: "DefaultApi",
Line 28: routeTemplate: "api/{controller}/{action}/{id}",
|
Source File: D:\Source\be\src\Foundation\Api\code\App_Start\WebApiConfig.cs Line: 26
Stack Trace:
[ArgumentException: A route named 'DefaultApi' is already in the route collection. Route names must be unique.
Parameter name: name]
System.Web.Routing.RouteCollection.Add(String name, RouteBase item) +391
System.Web.Http.HttpRouteCollectionExtensions.MapHttpRoute(HttpRouteCollection routes, String name, String routeTemplate, Object defaults) +21
Infocentric.Sc.Foundation.Api.WebApiConfig.Register(HttpConfiguration config) in WebApiConfig.cs:26
Infocentric.Sc.Foundation.Api.WebApiConfig.Start() in WebApiConfig.cs:19
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +260
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +142
WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +81
WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +699
WebActivatorEx.StartMethodCallingModule.Init(HttpApplication context) +122
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +581
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +714
|
Solution:
I renamed the namespaces without removing associated bin and output files. Manually delete the bin and obj folders from the output directory. Rebuild or cleaning the solution is not enough.
Thanks. This helped.
ReplyDelete