Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have two questions as below:

First,I provided the file download functionality to the user, but when user copies the URL and paste in another browser, I do not want the download to get started start, instead I want this to be started only when user navigates from link in the application.

Second how to prevent file browsing in asp.net? I tried

<directoryBrowse enabled="false"/>

in web.config. but was not useful.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
675 views
Welcome To Ask or Share your Answers For Others

1 Answer

got the solution,

Option 1.you can add the web.config file to the directory in which the file you want to restrict the access exist and add following lines to the web.config

<configuration>
  <system.web>
   <authorization>
    <deny users="?"/>
   </authorization>
  </system.web>
</configuration>  

OR

Option 2. You can add following lines to the existing root web.config.

<configuration>
<location path="DirectoryName">
    <system.web>
        <authorization>
            <deny users="?"/> <!-- Denies Anonymous Users -->
        </authorization>
    </system.web>
</location>
</configuration>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...