简体   繁体   中英

ASP.NET MVC Can I have a controller called PropertiesController?

I am trying to learn asp.net MVC.

I have created a model called Property, I have then created a controller called PropertiesController. However when I run my code I get a 403 error when navigating to /Properties

If I rename my controller to Properties1Controller and navigate to /Properties1 it works.

I assume there is a conflict between the name of my controller and the Properties folder (mine contains AssemblyInfo.cs).

Is there a way around this or is it best to avoid controllers called Properties?

There is a conflict here. In your project you already have a Properties folder which holds the AssemblyInfo.cs file. I'd choose a different name for your controller.

It may be possible to get working with routing but in reality it's much simpler in the long run to stay away from anything non standard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM