Link to home
Start Free TrialLog in
Avatar of WingYip
WingYip

asked on

Secure PDF files in Asp.net

Hi
We are using forms authentication in .net to restrict access to tthe site.  We also need to restrict access to a directory containing PDF files.

I have done the following
Added the web.config file in the attached code snippet to this directory
In the mappings section of IIS app configuration I have added .pdf as an application extension.
restarted iis

However what happens is this.

When clicking on a link to one of the secured pdf files, we are redirected to the login page which is what I want to happen.

However, once logged in, the links to the pdf files cause a 'cannot display page' error in ie.

So the files are being secured but they can no longer be displayed even when logged in

Anyone any ideas

Wing
<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<system.web>
		<authorization>
			<deny users="?" />
		</authorization>
	</system.web>
</configuration>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of devlab2012
devlab2012
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mortimer452
mortimer452

I think the Deny users="?" is denying everyone -- you need an allow list in there somewhere.
Avatar of WingYip

ASKER

Thanks

That did it