How can we make controller classes without suffixing "Controller" in the class name?
-
4This is part of MVC's Convention Over Configuration philosophy. You may be able to change this convention, but why would you want to?UpTheCreek– UpTheCreek2011-05-10 10:13:51 +00:00Commented May 10, 2011 at 10:13
-
3Why would you want to defy the convention? It makes things much easier on other developers who have to maintain the code.Colin Mackay– Colin Mackay2011-05-10 10:14:07 +00:00Commented May 10, 2011 at 10:14
-
.net mvc is opensource technology, you can dowload sourses and rewrite all mvc source code to the way that you wantEvgeniy Labunskiy– Evgeniy Labunskiy2011-05-10 10:22:29 +00:00Commented May 10, 2011 at 10:22
-
Are there any examples available for this?sobsinha– sobsinha2011-05-10 10:34:30 +00:00Commented May 10, 2011 at 10:34
Add a comment
|
1 Answer
It is convention by default and is implemented in DefaultControllerFactory Class. You could create your own controller factory class that implements IControllerFactory and then use the code in Global.asax to make application use your controller factory
protected void Application_Start()
{
...
ControllerBuilder.Current.SetControllerFactory(MyControllerFactory);
...
}