('/' 应用程序中的服务器错误。找不到文件)Windows Azure 中的错误

发布于 2024-11-13 07:23:33 字数 2175 浏览 4 评论 0原文

我已将我的 ASP.NET Web 项目转换为云服务。当我在本地机器上编译它时,它工作正常。但是当我将其部署在 Windows Azure 上并将其作为 *.cloudapp.net 运行时,它显示以下错误。它不上传或下载任何文件。任何帮助将不胜感激。谢谢!

错误:`“/”应用程序中出现服务器错误。

找不到文件“E:\approot\uploads\129517348374782571”。

描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

异常详细信息:System.IO.FileNotFoundException:找不到文件“E:\approot\uploads\129517348374782571”。

源错误:

当前 Web 请求执行期间生成未处理的异常。有关异常来源和位置的信息可以使用下面的异常堆栈跟踪来识别。

堆栈跟踪:

[FileNotFoundException:找不到文件“E:\approot\uploads\129517348374782571”。] System.IO.__Error.WinIOError(Int32 errorCode, String MaybeFullPath) +12892807 System.IO.FileInfo.get_Length() +12550108 EsraSon2.CourseList.gvPaths_SelectedIndexChanged(对象发送者,EventArgs e)位于 C:\Users\canosum\documents\visual studio 2010\Projects\EsraSon2\EsraSon2\CourseList.aspx.cs:78 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e,布尔原因Validation,字符串validationGroup)+1203 System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,布尔 includeStagesAfterAsyncPoint)+3691 `

上传代码:

 string temp = DateTime.Now.ToFileTime().ToString();
                FileUpload1.PostedFile.SaveAs(Server.MapPath("uploads") +"\\"+ temp);
                BLLFileUpload m_helper = new BLLFileUpload();
                DateTime date = DateTime.Now;
                m_helper.InsertUploadFiletoDB(temp, FileUpload1.FileName, date, 1, Convert.ToInt32(gvSemesters.SelectedRow.Cells[7].Text));

下载代码:

BLLFileUpload m_helper = new BLLFileUpload();

            string tempname = m_helper.getFileRealName(gvPaths.SelectedRow.Cells[2].Text);  
            string fName = Server.MapPath("uploads")+ "\\" + tempname;
            FileInfo fi = new FileInfo(fName);
            long sz = fi.Length;

            Response.ClearContent();
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}", gvPaths.SelectedRow.Cells[3].Text));
            Response.AddHeader("Content-Length", sz.ToString("F0"));
            Response.TransmitFile(fName);
            Response.End();

I have converted my asp.net web project to Cloud Service. When i compile it on my local machine, it works fine. But when i deploy it on Windows Azure, and run it as *.cloudapp.net , it shows following error. It doesn't upload or download any file. Any help will be appreciated. Thanks!

Error :`Server Error in '/' Application.

Could not find file 'E:\approot\uploads\129517348374782571'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not find file 'E:\approot\uploads\129517348374782571'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[FileNotFoundException: Could not find file 'E:\approot\uploads\129517348374782571'.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +12892807
System.IO.FileInfo.get_Length() +12550108
EsraSon2.CourseList.gvPaths_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\canosum\documents\visual studio 2010\Projects\EsraSon2\EsraSon2\CourseList.aspx.cs:78
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +1203
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691
`

upload code :

 string temp = DateTime.Now.ToFileTime().ToString();
                FileUpload1.PostedFile.SaveAs(Server.MapPath("uploads") +"\\"+ temp);
                BLLFileUpload m_helper = new BLLFileUpload();
                DateTime date = DateTime.Now;
                m_helper.InsertUploadFiletoDB(temp, FileUpload1.FileName, date, 1, Convert.ToInt32(gvSemesters.SelectedRow.Cells[7].Text));

Download Code :

BLLFileUpload m_helper = new BLLFileUpload();

            string tempname = m_helper.getFileRealName(gvPaths.SelectedRow.Cells[2].Text);  
            string fName = Server.MapPath("uploads")+ "\\" + tempname;
            FileInfo fi = new FileInfo(fName);
            long sz = fi.Length;

            Response.ClearContent();
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}", gvPaths.SelectedRow.Cells[3].Text));
            Response.AddHeader("Content-Length", sz.ToString("F0"));
            Response.TransmitFile(fName);
            Response.End();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坠似风落 2024-11-20 07:23:33

根据您运行的实例数量,无法保证文件上传到您尝试下载的同一台计算机,因为存在多个服务器。

您需要保留的所有内容(例如上传的文件)都应存储在 Blob 存储中。

这是一个示例(适用于大文件)

http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/687b2252-8b5e-473d-b522-ebb6b02693b7

Depending on how many instances you are running, there is no guranttee that the file was upload to the same machine you are trying to download from since there are multiple servers.

All things that you need to persist, such as uploaded files should go to blob storage.

Here is a sample (for large files)

http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/687b2252-8b5e-473d-b522-ebb6b02693b7

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文