Reputation: 1
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);
}
}
Upvotes: 0
Views: 358
Reputation: 7402
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
Upvotes: 0
Reputation: 2307
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
Upvotes: 0