【问题标题】:(Server Error in '/' Application. Could not find file )error in Windows Azure(“/”应用程序中的服务器错误。找不到文件)Windows Azure 中的错误
【发布时间】:2011-06-05 08:37:02
【问题描述】:

我已将我的 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 C:\Users\canosum\documents\visual studio 2010\Projects\EsraSon2\EsraSon2\CourseList.aspx.cs:78 中的 EsraSon2.CourseList.gvPaths_SelectedIndexChanged(Object sender, EventArgs e) System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean CauseValidation, String 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();

【问题讨论】:

    标签: c# asp.net windows azure cloud-hosting


    【解决方案1】:

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

    所有需要持久化的东西,例如上传的文件,都应该放到 blob 存储中。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-07
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 2017-09-18
      • 1970-01-01
      • 2016-04-10
      • 1970-01-01
      相关资源
      最近更新 更多