Andrei Iovan
Andrei Iovan

Reputation: 113

PDF is not accessible through URL in IIS .NET Framework 4.8 app

I have a PDF file in a folder on a server within a IIS website app that I need to be able to open through a link/url, like below:

https://api.example.com/my-path/my-pdf-file.pdf

The PDF file is hosted in a folder of my IIS application. When I try to access it through the link, I've got a 500 server error.

I tried several things within IIS settings (URL Rules, web.config, mime-types), but nothing worked so far.

Any advice will be much appreciated.

enter image description here

Upvotes: -1

Views: 1153

Answers (2)

John Max
John Max

Reputation: 1

Change the URL from existing https://api.example.com/my-path/my-pdf-file.pdf to file://api.example.com/my-path/my-pdf-file.pdf.

Upvotes: -1

Albert D. Kallal
Albert D. Kallal

Reputation: 49264

Is the folder included in the project? You can't just add a folder outside of Visual Studio, but have to use VS to add that folder.

You can right click on that existing folder (which of course is a sub folder of your project) and check this setting:

So, in my case, I right click on UpLoadFiles.

If the folder ALREADY is included in the project, then you get a option to EXCLUDE the folder like this:

enter image description here

However, if the folder is not included, then you see this:

enter image description here

so, is that folder included in your project? You want to check above.

Upvotes: 0

Related Questions