开发者

Obtaining controller Type from string action, string controller, object routeValues information

In an ASP.NET MVC 2 application, how would I obtain the Type of the controller that would be used, given the information about the route: string action, string controller, object routeValues?

(The rout开发者_如何转开发eValues object might look like this new {area="admin"} and route to a controller for a different site area.)


The out of the box controller factory uses convention to find the controller type. I believe the convention is the controller name prepended to the word controller. For example if the controller name is 'home' then the type would be 'homecontroller'. By convention it is expecting to find this type in the controllers folder.

BTW, I believe the asp.net mvc code is open source. You can learn the exact conventions there.

Hope this helps.

Bob

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜