Try your self the following Code to get the physical Application Directory path and the assembly information:
public class MyTestController : Controller
{
private readonly IHostingEnvironment _hostingEnvironment;
public MyTestController(IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
}
// GET: api/MyTest
[HttpGet]
public IEnumerable<string> Get()
{
var currentDirectory = Directory.GetCurrentDirectory();
var appLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
var basePath = AppDomain.CurrentDomain.BaseDirectory;
var basePath2 = AppContext.BaseDirectory;
var basePath3 = ApplicationEnvironment.ApplicationBasePath;
var appName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
var appVersion = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
string webRootPath = _hostingEnvironment.WebRootPath;
string contentRootPath = _hostingEnvironment.ContentRootPath;
return new string[] { "value1", "value2" };
}
}
No comments:
Post a Comment