[英]Access mapped drive by IIS running asp.net mvc web application
I have deployed an asp.net mvc web application on IIS 8 server inside an virtual machine (Windows server 2012 R2). 我在虚拟机(Windows Server 2012 R2)中的IIS 8服务器上部署了一个asp.net mvc Web应用程序。 An azure file storage is mapped as network drive in this virtual machine Windows server 2012 R2.
在此虚拟机Windows Server 2012 R2中,azure文件存储被映射为网络驱动器。 Now my asp.net mvc web application needs to read the files and folders of this mapped drive by C# System.IO code.
现在我的asp.net mvc Web应用程序需要通过C#System.IO代码读取此映射驱动器的文件和文件夹。 By default IIS is not allowed to access mapped drives.
默认情况下,不允许IIS访问映射的驱动器。
That's why the web application is throwing System.IO exception 这就是Web应用程序抛出System.IO异常的原因
"Could not find the specified path Z:\\"
“找不到指定的路径Z:\\”
. 。 I also tried to pass
"\\\\\\\\{storage-name}.file.core.windows.net\\\\{fileshare-name}
but still no success. 我也尝试传递
"\\\\\\\\{storage-name}.file.core.windows.net\\\\{fileshare-name}
但仍未成功。
Can some one guide me with correct configurations and settings which I should do inside IIS and web application? 有人可以指导我在IIS和Web应用程序中进行正确的配置和设置吗?
Finally, I succeeded to access the mapped network drive through IIS Server. 最后,我成功通过IIS服务器访问映射的网络驱动器。 I performed following steps.
我执行了以下步骤。
That's it. 而已。 Now you can simply write standard C# IO code to access the directory and files of mapped drive.
现在您可以简单地编写标准C#IO代码来访问映射驱动器的目录和文件。 Here is a sample example.
这是一个示例示例。
var allDirs = Directory.GetDirectories("\\\\<storageaccountname>.file.core.windows.net\\<storagefileshare>");
ViewBag.Items = allDirs;
Make sure that you access the files and folders by UNC path format only, just like I have done in above code. 确保您只能通过UNC路径格式访问文件和文件夹,就像我在上面的代码中所做的那样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.