I'm having a tricky issue (bear with me as I'm new to MVC) with trying to use a controller (and a route subsequently) with the name PropertiesController.
I believe this is because there is a directory (which I can't really remove) called "Properties" in my solution. Is there a way round this?
The route setup is just one simple route:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Properties", action = "List", id = "" } // Parameter defaults
);
and the error I get in IIS7 when requesting "http://localhost/aptment2/properties/" is:
Surely there is a way round this that I just can't find? Cheers.
-
Running a quick test, I get the same behavior. Is it a viable option to use something other than Properties?
Kieran Benton : I'd prefer not to if at all possible, after all the idea of MVC is that you have complete control and your URL naming scheme is to be as clean as possible!mannish : Well, sort of. That's the idea behind routing, not necessarily just MVC, but regardless, MVC reles on certain conventions and that includes not using reserved words or names of other resources. I would suggest either looking into locking down that route definition further (I'll add an edit with a suggestion) or coming up with a different name for your controller.mannish : I tried locking down the route a bit further and get the same result. You might be SOL on this but I'll be curious to see if there's a way around it.Kieran Benton : Looks like you're right - oh well, will have to get my thesaurus out!mannish : FWIW, we have a controller called PropertyController that works just fine in one of our projects. But we have a convention of using singular names for controllers (as opposed to plural such as 'Properties'). -
I don't know if it's an option for you, but you could try to disable routing to existing files.
routes.RouteExistingFiles = false;
-
Since someone else is having the same problem, I'm guessing that you're running into a reserved keyword here (I imagine ClassControllers are out as well).
It's not the first time it's happened either - digging deeper into the internals of the environment, you can't route to Windows' reserved keywords either.
0 comments:
Post a Comment