Reputation: 5859
I've been trying to get the application path for my project on the Application_Start event in the global asax I can use server.mappath on pages that aren't routed but when i am on a routed page i get the new virtual path is there a way of getting the application path on startup i can't use Request or session or HttpContext.items[key] at that level does anyone know what to do
Upvotes: 6
Views: 4049
Reputation: 2098
This is the solution: http://msdn.microsoft.com/en-us/library/system.web.hosting.hostingenvironment.aspx
Upvotes: 7
Reputation: 7438
Why don't you use Application_BeginRequest to map path everytime?
There you can use
HttpApplication.Request.RawUrl
to get the requested path and later you can rewrite it with mapped path using
HttpContext.Current.RewritePath
Upvotes: -1