Hello, I've googled this extensively but haven't been able to find an answer to this question.
Also not through the post on this forum: http://forums.asp.net/p/1020158/1378995.aspx#1378995
Having a website working with forms authentication to force a disclaimer agreement I stumbled upon the following.
Users could just type in the direct url to a pdf file and then still obtain it.
So following this guide: http://geekswithblogs.net/ranganh/archive/2005/04/25/37592.aspx I was able to successfully force a redirect to the login form.
However when I tried to approach the pdf file after (succesful) login I stumbled upon a network error.
So after googeling even more I found that some extra settings needed to be added to the web.config.
This then worked, however I keep getting this strange error:
Sometimes the ascii style code contents of the pdf file is displayed.
Other times I get an empty pdf file (it has the same number of pages as the original).
When I go to the server through remote desktop I can open the pdf files perfectly.
This is my web.config:
Under IIS 6.0 and asp.net 2.0 running on server 2003
The 2 ad path lines are there because I am too much of a newbie to actually understand which one to use.
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<httpHandlers>
<add path="*.pdf" verb="*" type="System.Web.HttpForbiddenHandler" validate="True" />
<add path="*" verb="GET,HEAD,POST" type="System.Web.DefaultHttpHandler" validate="True" />
<add verb="GET, HEAD, POST, DEBUG" path="*.pdf" type="System.Web.UI.PageHandlerFactory"/>
</httpHandlers>
<compilation debug="false" strict="false" explicit="true">
<buildProviders>
<add extension=".pdf" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>
<authentication mode="Forms">
<forms loginUrl="form.aspx" name=".ASPXFORMSAUTH" defaultUrl="default.aspx">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
<customErrors mode="Off"/>
</system.web>
</configuration>