简体   繁体   English

需要从Azure上托管的.net网站访问目录

[英]Need to access a directory from .net website hosted on Azure

I have an Asp.net website hosted on Azure. 我在Azure上托管了一个Asp.net网站。 It has an upload excel file functionality so a Fileupload control is in play. 它具有上载excel文件功能,因此可以使用Fileupload控件。

string fileToSave = ConfigurationManager.AppSettings["DirectoryLocation"] + FileUpload.FileName;
FileUpload.PostedFile.SaveAs(fileToSave);

This works fine in traditional IIS servers but in Azure I am not sure what path to give in for "ConfigurationManager.AppSettings["DirectoryLocation"]". 在传统的IIS服务器中,此方法工作正常,但在Azure中,我不确定为“ ConfigurationManager.AppSettings [“ DirectoryLocation”]“指定的路径。

I have tried some shared location but looks like it cannot access those. 我尝试了一些共享位置,但看起来无法访问这些位置。

Please give me some direction. 请给我一些方向。

In contrast to a web application that is hosted on a local IIS your application can run on several instances in Azure that you do not have control over. 与本地IIS上托管的Web应用程序相比,您的应用程序可以在不受控制的Azure中的多个实例上运行。 It even can be moved to another server under certain circumstances. 在某些情况下,甚至可以将其移动到另一台服务器。 So using a local file system folder is not an option. 因此,使用本地文件系统文件夹不是一种选择。 Instead, you have to use a store that you can access from all the instances. 相反,您必须使用可以从所有实例访问的存储。

Have a look at the following overview of Azure Storage under this link . 在此链接下查看以下Azure存储概述。 Typically, you would store files in a Blob or a File Storage. 通常,您会将文件存储在Blob或文件存储中。 On this site, you can also find some samples on how to access the storage from the cloud (and later on from an on-premise application that processes the data). 在此站点上,您还可以找到一些有关如何从云中访问存储的示例(以及稍后从处理数据的本地应用程序中访问示例)。

This code should work but I would recommend you to store files in blob storage. 该代码应该可以工作,但是我建议您将文件存储在Blob存储中。 See https://azure.microsoft.com/fr-fr/documentation/articles/storage-dotnet-how-to-use-blobs/ 请参阅https://azure.microsoft.com/fr-fr/documentation/articles/storage-dotnet-how-to-use-blobs/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从asp.net网站访问本地自托管WCF服务 - access local self-hosted WCF service from asp.net Website 透明地分解Azure中托管的ASP.NET网站 - Transparently decomposing an ASP.NET Website hosted in Azure 如何从托管在 Azure 应用服务中的 .Net Framework Asp.Net 应用程序访问 Azure KeyValut? - How do I access an Azure KeyValut from an .Net Framework Asp.Net application hosted in an Azure App Service? 来自IIS中托管的网站的SOAP API访问错误 - SOAP API access error from a website hosted in IIS 在旧的Asp.net网站上对Active Directory Azure进行身份验证 - Authentification Active Directory Azure on an old Asp.net WebSite 从作为 Azure Web 应用程序托管的 ASP.NET 5 应用程序进行日志记录 - Logging from ASP.NET 5 application hosted as Azure Web App 此外,密码保护作为 Azure WebApp 托管的 ASP.NET Core MVC 网站和现有身份验证 - Additionally password protect an ASP.NET Core MVC website hosted as Azure WebApp with existing authentication 如何配置ASP.Net网站以访问Active Directory - How to configure ASP.Net website to have access to Active Directory 您可以在ASP.NET网站之外访问虚拟目录吗? - Can you access a Virtual Directory outside of an ASP.NET website? 使用Azure上托管的ASP.NET Core Web应用程序将文件上传到目录 - Uploading files to a directory with an ASP.NET Core Web Application hosted on Azure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM