I have the most routing problem that I can not work to avoid, in our application we have two fields , And both of them have an employee controller so we have these two valid URLs:
blah.com/Employees/Employees blah.com/Reports/Employees
The route is registered as follows :
Public override Zero RegisterArea (AreaRegistrationContext Reference) {context.MapRoute ("Employees_default", "Employee / {Controller} / {of} Revision} / {ID} ", new {action =" index ", id = UrlParameter.Optional}); } Public override request register area (area registrations contact reference) {reference.MapRoute ("reports_default", "report / {controller} / {action} / {id}", new {action = "index", id = UrlParameter.Optional} ); } Now everything works as expected, but the problem enters a person and is the wrong URL, such as:
blah.com/Employees
which generates the following error:
Several types were found which match the 'Employee' controller. It may be that if this request The routes for the services of ('{controller} / {action} / {id}') do not specify a namespace to find the controller that matches the request Is. If this is the case, then by registering the surcharge of the 'margarout' method, register this route which takes the 'namespace' parameter. The employee has been found in the following matching controllers for the request: blah.Admin.Areas.Employees.Controllers.EmployeesController blah.Areas.Reports .Controllers.EmployeesController It is not. I understand that whenever the area is unavailable from the path, then any attempt to match any of those two routes Will? Routes clearly include the name of the area, and this is not optional?
I also have found that if I have another valid controller for another route, then say this:
blah .com / Tools / ErrorLog
That if I enter blah.com/ErrorLog, then it actually runs the tool / error logger controller, but it is in an effort to find ideas. Any idea what's here?
You need to use Public override Zero RegisterArea (AreaRegistrationContext Reference) {reference.MapRoute ("Employees_default", "employee / {controller} / {action} / {id}", new {action = "index" , ID = UrlParameter.Optional}, new [] {Mysolution.Myproject.Employees}); } Public override request register area (reference to the area registration) {reference.maproot ("reports_default", "report / {controller} / {action} / {id}", new {action = "index", id = UrlParameter. Optional}, new [] {Mysolution.Myproject.Reports}); }
No comments:
Post a Comment