0

I can upload a .xlsx file on my website running locally but it 404's after publishing to Azure. ASP.Net/webforms; C#;

"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

Any ideas would be appreciated.

if (!this.FileUpload1.FileName.Equals("ActionFile.xlsx"))
{
    this.tbxAdminStatus.Text = "Missing input file ActionFile.xlsx";
    return;
}
else
{
    // Upload file
    fileLoc = Server.MapPath("~/Upload/" + his.FileUpload1.PostedFile.FileName);

    try
    {
         this.FileUpload1.PostedFile.SaveAs(fileLoc);
         this.tbxAdminStatus.Text = "File ActionFile.xlsx Uploaded";
    }
    catch (Exception ex)
    {
        Response.Write("Error: " + ex.Message);
    }
}
MSM
  • 1

2 Answers2

0

Are you saying that when you browse to .xslx file directly from browser then you get the 404 error even if the file exists??? For 404's, the substatus code is really helpful to identify why a 404 is returned so you may want to check the IIS Logs for your site to see the substatus and see if the substatus code corresponds to missing mime map (404.3)

If the substatus code for 404 is 3 then you can add the mimemap for excel extension as explained in a similar article on stack overflow Use SVG in Windows Azure Websites

For more details refer to http://blogs.iis.net/tomkmvp/troubleshooting-a-404

Community
  • 1
  • 1
Puneet Gupta
  • 2,237
  • 13
  • 17
  • Thank you Puneet. I haven' t had much luck yet doing anything with logs or backups with Azure. It's not as easy as straight SQL Server/IIS. I'll have to add some code that verifies success at each step. It may be that the code I found to read the .xlsx file is failing due to the relative file path. Here is that code : foreach (var worksheet in Workbook.Worksheets(fileLoc)) { foreach (var row in worksheet.Rows) { – MSM Jul 01 '15 at 15:49
0

You need to define a MimeType for .xslx files to let the webserver serve them over http.

in your web.config add these lines

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <remove fileExtension=".xlxs" />
      <mimeMap fileExtension=".xlxs" mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
    </staticContent> 
  </system.webServer>
</configuration>

source for MimeType value: https://stackoverflow.com/a/4212908/3234163

Community
  • 1
  • 1
ahmelsayed
  • 7,125
  • 3
  • 28
  • 40