I am currently using App_data to store the dynamically created PDFs, Finding full path using:
String Location = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
However, ASP.NET MVC3 doesn’t allow me to embed from this location. with 403 problem.
<embed src="@Url.Content("~/App_Data/test.pdf")" width="100%" height="500px" />
Researching, this is the desired of the App_data folder.
-
So, how can I embed from this directory. or is there a better directory for this? I can access it fine from Content folder, but it seems the wrong place. (and how would I get the absolute path for the given folder)
-
What is the App_Data folder for???
You can’t embed directly from this folder as you’ve found. You can either create a temp folder in your content folder that you deliver the PDFs from (open to discoverability, and therefore not what I’d recommend) or you can write a handler that streams the document from the App_Data folder (which is what we do for a similar problem, except we use the OS’s temp folder) and reference that.
There are good answers in this question here