Reputation: 2821
I have an ASP.NET MVC 2 application that has page with a link to a pdf file
<a href="<%= Url.Content("~/Downloads/test1.pdf") %>">test1</a>
Downloads directory is at MVCApplication1/Downloads
This works fine locally and on ISS, but returns a page not found when uploaded to Azure.
Upvotes: 1
Views: 733
Reputation: 2821
In visualstudio in the pdf properties had to change the Build Action to Content and Copy to Output Dir to Copy always for this to work with Azure
Upvotes: 2
Reputation: 8017
Check the path that is being emitted in the HTML. Its likely relative to the Azure datacenter/cluster, and is meaningless to your client if your client is outside Azure.
If you see something like "http://RD1204900029029/Downloads/test1.pdf", thats your issue. You'll need to emit the actual path using application logic to account for some of the magic the load-balancer does on your behalf.
Best way to use URL information provided by the request itself. I'm not an ASP.NET master by any means, so there may be a cleaner way to do this (similar to Url.Content) but this will work
Try
HttpContext.Current.Request.Url.Host
so
<%
var host = System.Web.HttpContext.Current.Request.Url.Host;
%>
<a href="<%= host + "/Downloads/test1.pdf" %>">test1</a>
Upvotes: 2
Reputation: 66882
This is a guess...
But I think that perhaps the Azure IIS instance does not include PDF as a known MIME type.
To adjust for this try adding the mime type to your app's web.config file: http://blogs.iis.net/bills/archive/2008/03/25/how-to-add-mime-types-with-iis7-web-config.aspx
If this still doesn't work, then maybe consider:
Upvotes: 1