Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
Hi Dear Friends,

I have multiple files on web-server with different extension (e.g., .doc, .xls, .pdf, .mp3, .zip....).

Now, I want that if user access file name in link then that file should not be download, except the logged in user.

Example,
file name is "myfiles.zip"
link is http://www.mysite.com/myfiles.zip

So, if end user direct access http://www.mysite.com/myfiles.zip, then it should not download.

But if user is logged in the application then that file should download.

How to use in ASP.Net 2.0 and SQL 2005 ?

Please HELP me to resolve above issue.

Thanks in advance.

:-)

Rohit
Posted

1 solution

XML
hi,
Put your files (those you dont want to directly accesssible) under downloadfiles folder.
on web config put the codes given below,
<location path="downloadfiles">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>
This section should be placed out side <system.web> section
Target file will download if user login.
Hope this will  help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900