问题
I am trying to add a area to my application but it throws the below error at
context.MapRoute
I have system.web and system.web.mvc dlls referred in my application. What may be the issue?
My application is targeting .Net core 2.0
Any pointers please?
回答1:
If you're targeting your projecto to .Net core 2.0 and it's a ASP.NET Core, than you should follow these instructions on microsoft docs. You don't need those references to System.Web.
You can do area registration with MapRoute in your startup class for example, and the folder/file structure will do the rest:
...
app.UseMvc(routes =>
{
routes.MapRoute(
name: "areaRoute",
template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
来源:https://stackoverflow.com/questions/49417383/reference-to-type-route-claims-it-is-defined-in-system-web