I am trying to get the path to a folder in my website root and save it to a class property when my controller constructor is called:
public TestController:Controller{ string temp; public TestController(){ temp = ''; } }
I have tried the following:
temp = Server.MapPath('~/TheFolder/'); // Server is null - error. temp = Request.PhysicalApplicationPath + @'TheFolder\'; // Request is null - error.
Any ideas?
AppDomain.CurrentDomain.BaseDirectory will give you the root of your site. So:
(Update thanks to Marc Gravell’s comment)