Open PDF Content files in ASP.NET MVC 2
- by mcbingo
I want to provide simple href links to my PDF forms that reside in my Forms folder. I have a created a simple Index.aspx and FormController Index action that simple iterates through the list of PDF files using my FormMetaData.xml file. The links get created just fine but when you click on the links I get a 404 exception. That looks like this:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Forms/ccindteamgolfform.pdf
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
This seems like this should open up a new browser window with the PDF in it but perhaps I am making a bad assumption. The PDF content files have Build Action of Content and Copy to Output set to Copy Always. Here is an example output html for the link from my Index.aspx page:
<span class="form">
<a href="Forms/ccindteamgolfform.pdf" target="_blank">
<span class="description">Entry Form</span></span>
I must be missing something because this does not work. Do I need to add a MapRoute for these documents? Or am I missing something else with the routing? This seems like it should not be that difficult.