在 windows azure 上找不到路径的一部分 [英] Could not find a part of the path on windows azure

查看:29
本文介绍了在 windows azure 上找不到路径的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 windows azure 上部署了 mvc-3 应用程序.在我的应用程序中,我正在上传文件并将其保存在 App_Data/DownloadedTemplates 文件夹中.

I deployed mvc-3 application on windows azure. In my application i am uploading the file an save it in the App_Data/DownloadedTemplates folder.

  var path = Server.MapPath("~App_Data/DownloadedTemplates");

我的应用程序当前正在临时环境中运行.当我上传文件时,它在浏览器中显示一个异常:

my application is running on staging environment currently. When i uploaded file , it shows me an exception in the browser :

找不到路径F:sitesrootApp_DataDownloadedTemplatesB.htm_2c77cdfd-c597-4234-bd1e-29ca0a9b8d0e.htm"的一部分.

我正在使用 Server.MapPath 在服务器上定位 App_Data 的路径,现在为什么会出现这个异常?.谁能告诉我问题所在?

I am using Server.MapPath to locate the path of App_Data on the server, now why this exception ?. Can anybody tell me the problem ?

推荐答案

您不应该在 Windows Azure 应用程序中执行此操作.在 Windows Azure 中,您应该使用 LocalResources(专用磁盘上的保留空间) 用于在磁盘上保存临时文件,这是您应该存储数据的唯一位置.

You shouldn't be doing this in a Windows Azure application. In Windows Azure you should use LocalResources (reserved space on a dedicated disk) for saving temp files on the disk, this is the only place where you should store data.

以下是如何访问此类 LocalResource 的示例(名称和大小可以在 VS 项目中配置):

Here is an example of how you would access such a LocalResource (name and size can be configured in the VS project):

LocalResource localResource = RoleEnvironment.GetLocalResource("DownloadedTemplates");

不要忘记 LocalResources 中的数据可能会消失(例如,当机器崩溃时).如果您真的想保留数据,则应该使用 Windows Azure Blob 存储.

Don't forget that data in LocalResources might disappear (when the machine crashes for example). If you really want to persist your data, you should be using Windows Azure Blob Storage.

这篇关于在 windows azure 上找不到路径的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆