Search code examples
asp.net-mvc-3accessibilitypath-finding

MVC3 Using or Finding the ApplicationPath inside of the _Layout.cshtml page


I have a C#.Net web app and the pathing is different from my local box to the dev box. My local url is http://localhost:<port>/Proposal/Edit. However, on the dev server, it is http://{MydevServer}/dev/app/Proposal/Edit]. So, this causes issues with the Style Sheet and navigation links, etc. I know I can grab the ApplicationPath inside all the Controllers and set a variable whic the pathed elements can use. But that seems like too much work for this issue. Any ideas on how to solve this? Is it possible to get the ApplicaionPath in the _Layout.cshhml file? Is ther a better idea?


Solution

  • you should be using the Url.Action and Url.Content helper methods for generating your links and src attributes. then you'll never need to worry about it.