Reference to Type 'Route' claims it is defined in 'System.web'

风格不统一 提交于 2021-01-28 08:18:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!