11 HAZİRAN 2012, PAZARTESİ
Bir rota adlı "x" zaten rota koleksiyonunda. Rota adları benzersiz olmalıdır. ASP.NET istisna 3 MVC
ASP.NET MVC 3 web hizmeti yapıyorum ve bu durum, zaman zaman almaya devam ediyorum.
Yığın izleme:
Server Error in '/' Application.
A route named 'ListTables' 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 'ListTables' is already in the route collection. Route names must be unique.
Parameter name: name
Source Error:
Line 24: // }
Line 25: // );
Line 26: context.MapRoute(
Line 27: "ListTables",
Line 28: // example:
Source File: C:\inetpub\wwwroot\SchemaBrowserService\Website\Areas\Api\ApiAreaRegistration.cs Line: 26
Stack Trace:
[ArgumentException: A route named 'ListTables' is already in the route collection. Route names must be unique.
Parameter name: name]
System.Web.Routing.RouteCollection.Add(String name, RouteBase item) 2329682
System.Web.Mvc.RouteCollectionExtensions.MapRoute(RouteCollection routes, String name, String url, Object defaults, Object constraints, String[] namespaces) 236
System.Web.Mvc.AreaRegistrationContext.MapRoute(String name, String url, Object defaults, Object constraints, String[] namespaces) 59
System.Web.Mvc.AreaRegistrationContext.MapRoute(String name, String url, Object defaults) 17
SchemaBrowserService.Areas.Api.ApiAreaRegistration.RegisterArea(AreaRegistrationContext context) in C:\inetpub\wwwroot\SchemaBrowserService\Website\Areas\Api\ApiAreaRegistration.cs:26
System.Web.Mvc.AreaRegistration.CreateContextAndRegister(RouteCollection routes, Object state) 105
System.Web.Mvc.AreaRegistration.RegisterAllAreas(RouteCollection routes, IBuildManager buildManager, Object state) 199
System.Web.Mvc.AreaRegistration.RegisterAllAreas(Object state) 45
System.Web.Mvc.AreaRegistration.RegisterAllAreas() 6
Website.MvcApplication.Application_Start() in C:\Users\djackson\Downloads\RestApiMvc3\Website\Website\Global.asax.cs:35
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
Muhtemelen Rota Ayıklayıcı değiştirilmiş veya silinmiş olduğum bazı eski yollar olduğunu gösteren bir durum ile ilgili olduğunu ve makineyi yeniden başlatmadan sonra bile gitmek istemez. İzleme de çoktan silinmiş bir kaynak dosyası anlamına gelir yığını ve benim app yeni bir yer, ve o zamandan beri temizledim yeniden taşındı. Neyi kaçırıyorum?
Burada rota kaydı Şifremi:
// in Global.asax.cs:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default2", // Route name
"Api/{controller}/{action}/{id}", // URL with parameters
new { controller = "DataSource", action = "Index", area = "Api", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
}
// in ApiAreaRegistration.cs:
public class ApiAreaRegistration : AreaRegistration
{
public override string AreaName { get { return "Api"; } }
public override void RegisterArea(AreaRegistrationContext context)
{
// DataSources
// Tables
context.MapRoute(
"ListTables",
// example:
// /api/DataSources/DataSource/1/schemata/schema/dbo/tables
"Api/DataSources/DataSource/{dataSourceId}/schemata/{schemaName}/tables",
new
{
controller = "Tables",
action = "TableList",
schemaName = "dbo",
dataSourceId = "DefaultId"
}
);
// Schemata
context.MapRoute(
"Schema",
// example:
// /api/DataSources/DataSource/1/schemata/schema/dbo
"Api/DataSources/DataSource/{dataSourceId}/schemata/{schemaName}",
new
{
controller = "Schema",
action = "Schema",
dataSourceId = "DefaultId",
schemaName = UrlParameter.Optional
}
);
// // DataSources
context.MapRoute(
"SingleDataSource",
"Api/DataSources/DataSource/{dataSourceId}",
new
{
controller = "DataSource",
action = "DataSource",
dataSourceId = UrlParameter.Optional
}
);
context.MapRoute(
"ListDataSources",
"Api/DataSources",
new
{
controller = "DataSource",
action = "DataSourceList",
dataSourceId = "DefaultId"
}
);
context.MapRoute(
"Api_default",
"Api/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
CEVAP
14 AĞUSTOS 2012, Salı
Bu sorunu gidermek için projeme bin klasörü içine gidip tüm DLL dosyaları silmek ve yeniden oluşturmak zorunda kaldım ve bu sorun düzeltildi.
Bunu Paylaş:
ADT 22,3'ünü (android 4.4) - hata &quo...
kullanarak "raylar iskele oluştur...
Alma "Error loading MySQLdb modul...
Tam olarak "HİERARCHY_REQUEST_ERR...
ıpa " verme ile 6 beta 2 / Güncell...