ASP.NET5 MVC6中的App_Data目录 [英] App_Data directory in ASP.NET5 MVC6
本文介绍了ASP.NET5 MVC6中的App_Data目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试ASP.NET5 MVC6应用程序.在以前的版本中,有一个目录 App_Data .我使用此文件夹存储错误日志.但是找不到最新版本.有帮助吗?
I've been trying ASP.NET5 MVC6 app. In the previous version, there was a directory App_Data. I used this folder to store error logs. But it is not found in latest version. Any help?
推荐答案
这适用于具有Core 2的ASP.NET MVC
This works for ASP.NET MVC with Core 2
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Use this code if you want the App_Data folder to be in wwwroot
//string baseDir = env.WebRootPath;
// Use this if you want App_Data off your project root folder
string baseDir = env.ContentRootPath;
AppDomain.CurrentDomain.SetData("DataDirectory", System.IO.Path.Combine(baseDir, "App_Data"));
}
现在,您可以将这段代码放在需要的位置,以获取您的App_Data文件夹
Now you can put this code where you need it to get your App_Data folder
string dataDir = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
这篇关于ASP.NET5 MVC6中的App_Data目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文