Reputation: 1036
I'm sure this is very simple...I'm trying to link to a PDF file using Uri.Content but keep getting resource not found errors. The code I am using is:
<a href="@Url.Content("~/Views/MasterPlan/masterplanwithbackground.pdf")">Master Plan</a>
The PDF is located in the Views/MasterPlan directory - usual default MVC project structure.
Thanks.
Upvotes: 1
Views: 7014
Reputation: 17
Advertisement Notice
You can pass pdf url as dynamically in @url.content() of href="@url.content( )" . Its working fine.
Upvotes: -1
Reputation: 8539
Here is a similar question, but about different file types.
In view folder there is a web.config file, which contain this lines:
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
It blocks all request to this folder and its content.
Just create one more folder to store your documents, or place your pdf in folder where you store your ccs, js and image files.
Upvotes: 1
Reputation: 23937
You should not be able to route to files in your Views folder out of the box.
You should create a seperate folder called "docs", "documents" or "files" if you want to serve content directly from the filesystem and not from a database. Then there is also "seperation of concerns" - Your Views folder is responsible for containing and serving views to your controller.
The syntax of your Url.Content
is correct. Just the path / concept is incorrect.
Upvotes: 2