0

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Tried it, same issue
have you tried in this form HttpContext.Server.MapPath("App_Data/Guides/Information.pdf")?
0

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.

  • Open Directory C:\Windows\System32\inetsrv\config
  • Find applicationHost.config and Open it(Pay attention to use the administrator to open the way)
  • Find security/requestFiltering/hiddenSegments
  • Deletes the item <add segment="App_Data" /> and save

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.