Protect local data files from download?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: Protect local data files from download?

    Just make sure that the extension of the file is unkown to IIS. Give the
    file a name like data.xyz or something. Then IIS will never serve it up to
    anybody.

    --
    I hope this helps,
    Steve C. Orr, MCSD
    [url]http://Steve.Orr.net[/url]


    "Steve Brecher" <Steve_Brecher@see.sig.at.end> wrote in message
    news:OfJrx%23mQDHA.2432@TK2MSFTNGP10.phx.gbl...
    > The Global.asax.vb contains code called from Application_Start that opens
    > and reads some data files which in total contain about 35KB. For
    > portability of the web application (e.g., to one remote host or another)
    it
    > seems best to keep this data within the application directory or a
    > subdirectory thereof, so that its path can be obtained at runtime via
    > HttpContext.Current.Server.MapPath.
    >
    > Is there a way to allow the web app to open/read the data files but to
    > protect them from downloading by the user?
    >
    > --
    > For mail, please use my surname where indicated:
    > [email]steve@surname.reno.nv.us[/email] (Steve Brecher)
    >
    >

    Steve C. Orr, MCSD Guest

  2. Similar Questions and Discussions

    1. Finding data files in local directory
      Say I have a bunch of XML files in the directory with my web app (or in a subdirectory) and I want the app to be able to create a list of all...
    2. PayPal and Protect Download
      Hi all, I would like to setup a page where a customer can download a file they buy using PayPal. But, I want this page to be protected from them...
    3. Need to download data to local access database
      Have a web app (ASP classic) that saves data to an Access database on the web host. Need to come up with some sort of ASP admin tool that will...
    4. Protect files
      Hi, I need to distribute two projects, one on cd and one in a downloadable zip file. Everything is ready to go except for the fact that all...
    5. Protect FLV files
      Hi all, Anyboys knows what is best ways to protect FLV files (flash video files)? Thanks Behzad Peivasteh http://www.e-course.co.jp
  3. #2

    Default Re: Protect local data files from download?

    "Steve C. Orr, MCSD" <Steve@Orr.net> wrote:
    > Just make sure that the extension of the file is unkown to IIS. Give the
    > file a name like data.xyz or something. Then IIS will never serve it up
    to
    > anybody.
    The extension has been .csv (an Excel file type) and IE6 presents a download
    dialog. If I change the extension to .xyz or to .steve, IE6 displays the
    contents of the file (as it would if the extension were .txt).
    > "Steve Brecher" <Steve_Brecher@see.sig.at.end> wrote in message
    > news:OfJrx%23mQDHA.2432@TK2MSFTNGP10.phx.gbl...
    > > The Global.asax.vb contains code called from Application_Start that
    opens
    > > and reads some data files which in total contain about 35KB. For
    > > portability of the web application (e.g., to one remote host or another)
    > it
    > > seems best to keep this data within the application directory or a
    > > subdirectory thereof, so that its path can be obtained at runtime via
    > > HttpContext.Current.Server.MapPath.
    > >
    > > Is there a way to allow the web app to open/read the data files but to
    > > protect them from downloading by the user?
    --
    For mail, please use my surname where indicated:
    [email]steve@surname.reno.nv.us[/email] (Steve Brecher)


    Steve Brecher Guest

  4. #3

    Default Re: Protect local data files from download?

    Hi Steve,

    Just to expand on what Steve Orr said, you might want to use IIS mapping to
    prevent .csv files from being served.

    Open the IIS applet and open the Properties page for your Web application.
    On the Virtual Directory tab, click Configuration (in the Application Settings
    area).
    On the Mappings tab, create a new entry for .csv and map it the way .config,
    ..aspx and other .Net extensions are handled.

    This forces the .csv extension to use the
    C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspne t_isapi.dll as its handler.

    In the machine.config file, search for the <httpHandlers> section and add this:

    <add verb="*" path="*.csv" type="System.Web.HttpForbiddenHandler"/>

    When the handler checks the extension, it will refuse to serve it.

    You might be able to configure it more locally in the web.config file, not sure
    about that.

    Does this work for you?

    Ken
    MVP [ASP.NET]





    "Steve Brecher" <Steve_Brecher@see.sig.at.end> wrote in message
    news:OfJrx%23mQDHA.2432@TK2MSFTNGP10.phx.gbl...
    The Global.asax.vb contains code called from Application_Start that opens
    and reads some data files which in total contain about 35KB. For
    portability of the web application (e.g., to one remote host or another) it
    seems best to keep this data within the application directory or a
    subdirectory thereof, so that its path can be obtained at runtime via
    HttpContext.Current.Server.MapPath.

    Is there a way to allow the web app to open/read the data files but to
    protect them from downloading by the user?

    --
    For mail, please use my surname where indicated:
    [email]steve@surname.reno.nv.us[/email] (Steve Brecher)



    Ken Cox [Microsoft MVP] Guest

  5. #4

    Default Re: Protect local data files from download?

    Right after I explain how to do it, I find that there's a KB article!

    HOW TO: Use ASP.NET to Protect File Types

    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;815152[/url]

    "Steve Brecher" <Steve_Brecher@see.sig.at.end> wrote in message
    news:OfJrx%23mQDHA.2432@TK2MSFTNGP10.phx.gbl...
    The Global.asax.vb contains code called from Application_Start that opens
    and reads some data files which in total contain about 35KB. For
    portability of the web application (e.g., to one remote host or another) it
    seems best to keep this data within the application directory or a
    subdirectory thereof, so that its path can be obtained at runtime via
    HttpContext.Current.Server.MapPath.

    Is there a way to allow the web app to open/read the data files but to
    protect them from downloading by the user?

    --
    For mail, please use my surname where indicated:
    [email]steve@surname.reno.nv.us[/email] (Steve Brecher)



    Ken Cox [Microsoft MVP] Guest

  6. #5

    Default Re: Protect local data files from download?

    "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@sympatico.ca>:
    > Right after I explain how to do it, I find that there's a KB article!
    >
    > HOW TO: Use ASP.NET to Protect File Types
    >
    > [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;815152[/url]
    Thanks! But I may need a scheme for cases in which one doesn't control IIS
    configuration, such as a shared server at a commericial hosting company.
    Based on your and the KB article's instruction and after looking at
    machine.config I think that all that needs to be done is to rename the data
    files with extensions that won't be served, such as .vb, .cs, or .asp.
    > "Steve Brecher" <Steve_Brecher@see.sig.at.end> wrote in message
    > news:OfJrx%23mQDHA.2432@TK2MSFTNGP10.phx.gbl...
    > The Global.asax.vb contains code called from Application_Start that opens
    > and reads some data files which in total contain about 35KB. For
    > portability of the web application (e.g., to one remote host or another)
    it
    > seems best to keep this data within the application directory or a
    > subdirectory thereof, so that its path can be obtained at runtime via
    > HttpContext.Current.Server.MapPath.
    >
    > Is there a way to allow the web app to open/read the data files but to
    > protect them from downloading by the user?
    --
    For mail, please use my surname where indicated:
    [email]steve@surname.reno.nv.us[/email] (Steve Brecher)


    Steve Brecher Guest

  7. #6

    Default Re: Protect local data files from download?

    >Based on your and the KB article's instruction and after looking at
    >machine.config I think that all that needs to be done is to rename the data
    >files with extensions that won't be served, such as .vb, .cs, or .asp.
    Good idea. You might just be able to rename it .config or .vbproj so it won't
    get in the way of anything else.

    Ken



    Ken Cox [Microsoft MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139