Home » Microsoft TechnologiesRSS

How to retrieve url from another view of controller by code

Dear all


I want to know url of View from another controller.  The following is structure


Controller

     Home

     Account

View

     Home\Index.aspx

     Account\Login.aspx


Now, I want to goto Index view of controller Home from view Login of controller Account

I know  I can use method this.RediectToAction("Index", "Home") to do it but I don't want to method.  It will fail to redirect when view or controller renamed.

Please help


 

1 Answer Found

 

Answer 1

You can use the first "best practice" from here:

http://weblogs.asp.net/rashid/archive/2009/04/01/asp-net-mvc-best-practices-part-1.aspx

And if you don't want to do that, you can use a project called T4MVC where all the views, controllers etc. are exposed as properties of a class. Bing / google for it. 

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter