Reputation: 5414
I want to display PDF files in my View, the PDF files are stored in my App Data folder.
If i pass the directPath in the model like this: C:\Projekt\x\App_Data\Guides\Information.pdf
i get PDF error in my view.
<div class="embed-responsive embed-responsive-16by9">
<object class="embed-responsive-item" data="@Model.directPath" type="application/pdf">
<p>PDF error</p>
</object>
</div>
However if i add a Content folder to my c# project and put the file there, and change the path to data="Content/Information.pdf"
then the PDF will display.
How can i access the pdf files in App Data?
Upvotes: 0
Views: 1084
Reputation: 171
App_Data folder contains the application's local data storage. It usually contains data storage in the form of files (such as Access Microsoft or SQL Server Express Microsoft, XML files, text files, and any other files supported by the application). The contents of this folder are not processed by ASP.NET. This folder is the default location for the ASP.NET provider to store its own data. For data security, this folder is added to the request filter module to be set to deny access,Want to visit, to carry out the operation.
C:\Windows\System32\inetsrv\config
security/requestFiltering/hiddenSegments
<add segment="App_Data" />
and saveUpvotes: 0
Reputation: 60
Try to use Absolute path to this directory in your code. Something like
HttpContext.Server.MapPath("~/App_Data/Information.pdf");
This path syntax depends on your MVC model version.
Upvotes: 1