Finding ASP.NET MVC User Control

Posted by Dave on Stack Overflow See other posts from Stack Overflow or by Dave
Published on 2010-03-24T11:11:43Z Indexed on 2010/03/24 11:13 UTC
Read the original article Hit count: 153

Filed under:
|

I'm creating a custom ActionResult class and I need it to be able to operate on a UserControl. All of the examples I've found so far pass in the full path like so:

return MyResult("~/ControllerName/UserControlName.ascx", myModel);

But I'd like it to operate the same way as calling View(), i.e. I just pass in the name and MVC determines the correct route:

return MyResult("UserControlName", myModel);

Is there a way I can find out the correct route to the control without specifying it manually?

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about c#