Protect file with different extension from .aspx

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

  1. #1

    Default Protect file with different extension from .aspx

    Hi,
    I'm developing an asp.net application. I'm using form authentication.
    All runs with page aspx, but when I try to connect to a protected file
    diverse to an aspx (such as a PDF file) and I'm not authenticated , the
    application download the file instead of redirect to the predefined login
    page.
    Anyone can help me ?

    Best regards
    alex

    Alessandro Zucchi Guest

  2. Similar Questions and Discussions

    1. Can I password-protect a PDF file?
      I'm trying to set up a site with a 'members-only' area that contains PDF files. Is there some way to password-protect the files themselves, or do I...
    2. password protect an xml/rss file
      i need to assign an rss/xml file to each user this file will be accessed most likely through an rss aggregator (user/pass credentials for file)...
    3. Use asp.net to protect file types
      http://support.microsoft.com/?id=815152 (Edit the script mappings in Internet Services Mananger to protect pdf's with aspnet) I have a site...
    4. password protect .fla file ?
      Hi all Is there a way for me to password protect my .fla and .swf files ? So that ? say someone comes up to my desktop, and is prompted for a...
    5. including one aspx file in another aspx file
      Is there a way is asp.net that I can include another aspx file ?. We can do this in asp by using include statement.
  3. #2

    Default Re: Protect file with different extension from .aspx

    Hi,

    see this blog post

    Protect PDF, DOC and other file types with Forms Authentication
    [url]http://dotnetjunkies.com/WebLog/richard.dudley/archive/2004/05/21/14215.aspx[/url]

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU

    "Alessandro Zucchi" <AlessandroZucchi@discussions.microsoft.com> wrote in
    message news:396D536D-13DA-40A2-93DD-F26DE9C5B795@microsoft.com...
    > Hi,
    > I'm developing an asp.net application. I'm using form authentication.
    > All runs with page aspx, but when I try to connect to a protected file
    > diverse to an aspx (such as a PDF file) and I'm not authenticated , the
    > application download the file instead of redirect to the predefined login
    > page.
    > Anyone can help me ?
    >
    > Best regards
    > alex
    >

    Teemu Keiski Guest

  4. #3

    Default Re: Protect file with different extension from .aspx

    Create an ASPX page that'll download the file to the user.
    Example. [url]http://www.servername.com/getfile.aspx?filename=3928393293[/url]

    Now you can still use form authentication.

    Make sure in getfile.aspx to set your Content-Type and Content-Disposition
    properly.

    I did a similar thing for a client that wanted images sent from an AS/400
    computer to be displayed in a client browser, but only if a valid user was
    logged into the system.
    I also made sure that 3928393293 was only valid for the user that requested
    the image and that 3928393293 could only be used once. Some users bookmarked
    the URL but the client didn't want that.


    "Alessandro Zucchi" <AlessandroZucchi@discussions.microsoft.com> wrote in
    message news:396D536D-13DA-40A2-93DD-F26DE9C5B795@microsoft.com...
    > Hi,
    > I'm developing an asp.net application. I'm using form authentication.
    > All runs with page aspx, but when I try to connect to a protected file
    > diverse to an aspx (such as a PDF file) and I'm not authenticated , the
    > application download the file instead of redirect to the predefined login
    > page.
    > Anyone can help me ?
    >
    > Best regards
    > alex
    >
    >

    gabe garza Guest

  5. #4

    Default Re: Protect file with different extension from .aspx

    Hello!

    I have the same problem!! I already have tested the 'ISAPI ASP.NET
    Filter Redirection' for .htm and .html files and it works fine!!

    But what i can do for .pdf files? I want that user can read this files
    directly in the internet explorer window without need to download them...

    Any Idea?

    Thank you in advance.

    Best Regards,
    Juan Antonio

    gabe garza escribió:
    > Create an ASPX page that'll download the file to the user.
    > Example. [url]http://www.servername.com/getfile.aspx?filename=3928393293[/url]
    >
    > Now you can still use form authentication.
    >
    > Make sure in getfile.aspx to set your Content-Type and Content-Disposition
    > properly.
    >
    > I did a similar thing for a client that wanted images sent from an AS/400
    > computer to be displayed in a client browser, but only if a valid user was
    > logged into the system.
    > I also made sure that 3928393293 was only valid for the user that requested
    > the image and that 3928393293 could only be used once. Some users bookmarked
    > the URL but the client didn't want that.
    >
    >
    > "Alessandro Zucchi" <AlessandroZucchi@discussions.microsoft.com> wrote in
    > message news:396D536D-13DA-40A2-93DD-F26DE9C5B795@microsoft.com...
    >
    >>Hi,
    >>I'm developing an asp.net application. I'm using form authentication.
    >>All runs with page aspx, but when I try to connect to a protected file
    >>diverse to an aspx (such as a PDF file) and I'm not authenticated , the
    >>application download the file instead of redirect to the predefined login
    >>page.
    >>Anyone can help me ?
    >>
    >>Best regards
    >>alex
    >>
    >>
    >
    >
    >
    Juan Antonio Tubío Guest

  6. #5

    Default Re: Protect file with different extension from .aspx

    I think that the best solution is a 'mixed authentication' between
    'windows authentication' and 'forms authentication'. Setup 'Windows
    Authentication' to protect a full folder (automatically for all file
    types) and when the user try to access them, show a login form (can
    check the user in a custom database) and 'internally' do a 'Windows
    Login' with a Windows User.

    But i don't know hot to do it..

    gabe garza escribió:
    > Create an ASPX page that'll download the file to the user.
    > Example. [url]http://www.servername.com/getfile.aspx?filename=3928393293[/url]
    >
    > Now you can still use form authentication.
    >
    > Make sure in getfile.aspx to set your Content-Type and Content-Disposition
    > properly.
    >
    > I did a similar thing for a client that wanted images sent from an AS/400
    > computer to be displayed in a client browser, but only if a valid user was
    > logged into the system.
    > I also made sure that 3928393293 was only valid for the user that requested
    > the image and that 3928393293 could only be used once. Some users bookmarked
    > the URL but the client didn't want that.
    >
    >
    > "Alessandro Zucchi" <AlessandroZucchi@discussions.microsoft.com> wrote in
    > message news:396D536D-13DA-40A2-93DD-F26DE9C5B795@microsoft.com...
    >
    >>Hi,
    >>I'm developing an asp.net application. I'm using form authentication.
    >>All runs with page aspx, but when I try to connect to a protected file
    >>diverse to an aspx (such as a PDF file) and I'm not authenticated , the
    >>application download the file instead of redirect to the predefined login
    >>page.
    >>Anyone can help me ?
    >>
    >>Best regards
    >>alex
    >>
    >>
    >
    >
    >
    Juan Antonio Tubío Guest

  7. #6

    Default Re: Protect file with different extension from .aspx

    Juan,

    Technically the PDF file has to be sent to the client browser so matter
    what, it's still "downloading" no matter how you look at it.

    Just make sure to set the Content-Type and Content-Disposition properly in a
    "getfile.aspx" or what every you named the aspx file.
    The PDF file, if the client has installed Acrobat Reader, will display the
    PDF in IE, Firefox, Safari, etc...
    If a client hasn't installed Acrobat Reader then they'll get a "Open", "Save
    As" dialog box.

    Gabe


    "Juan Antonio Tubío" <jatubio@saluddigital.net> wrote in message
    news:424B02A5.5020003@saluddigital.net...
    > Hello!
    >
    > I have the same problem!! I already have tested the 'ISAPI ASP.NET Filter
    > Redirection' for .htm and .html files and it works fine!!
    >
    > But what i can do for .pdf files? I want that user can read this files
    > directly in the internet explorer window without need to download them...
    >
    > Any Idea?
    >
    > Thank you in advance.
    >
    > Best Regards,
    > Juan Antonio
    >
    > gabe garza escribió:
    >> Create an ASPX page that'll download the file to the user.
    >> Example. [url]http://www.servername.com/getfile.aspx?filename=3928393293[/url]
    >>
    >> Now you can still use form authentication.
    >>
    >> Make sure in getfile.aspx to set your Content-Type and
    >> Content-Disposition properly.
    >>
    >> I did a similar thing for a client that wanted images sent from an AS/400
    >> computer to be displayed in a client browser, but only if a valid user
    >> was logged into the system.
    >> I also made sure that 3928393293 was only valid for the user that
    >> requested the image and that 3928393293 could only be used once. Some
    >> users bookmarked the URL but the client didn't want that.
    >>
    >>
    >> "Alessandro Zucchi" <AlessandroZucchi@discussions.microsoft.com> wrote in
    >> message news:396D536D-13DA-40A2-93DD-F26DE9C5B795@microsoft.com...
    >>
    >>>Hi,
    >>>I'm developing an asp.net application. I'm using form authentication.
    >>>All runs with page aspx, but when I try to connect to a protected file
    >>>diverse to an aspx (such as a PDF file) and I'm not authenticated , the
    >>>application download the file instead of redirect to the predefined login
    >>>page.
    >>>Anyone can help me ?
    >>>
    >>>Best regards
    >>>alex
    >>>
    >>>
    >>
    >>
    >>
    >

    gabe garza Guest

  8. #7

    Default Re: Protect file with different extension from .aspx

    There are two main ways to accomplish this...

    1) have asp.net protect the file
    2) have windows ntsf protect the file

    For 1).
    You need to have IIS send the requested file to ASP.NET. To accomplish this
    go into IIS application virtual directory->Home Directory->Mappings.
    Edit/Add the .pdf to the asp.net frameworks executable path (see .aspx).
    Uncheck check file exists. Now asp.net will now receive the request. From
    here you might want to implement a httpHandler and stream the file out.

    For 2).
    Create a new role in windows called 'pdfer' or whatever. Set all prfs to be
    read by this role (and sysem admin and so forth) but not iusr_xxx. When
    doing form authentication, set the identity of this user to also include
    this role.

    Hope that helps
    Joe

    "Alessandro Zucchi" <AlessandroZucchi@discussions.microsoft.com> wrote in
    message news:396D536D-13DA-40A2-93DD-F26DE9C5B795@microsoft.com...
    > Hi,
    > I'm developing an asp.net application. I'm using form authentication.
    > All runs with page aspx, but when I try to connect to a protected file
    > diverse to an aspx (such as a PDF file) and I'm not authenticated , the
    > application download the file instead of redirect to the predefined login
    > page.
    > Anyone can help me ?
    >
    > Best regards
    > alex
    >
    >

    Yahoo Guest

  9. #8

    Default Re: Protect file with different extension from .aspx

    Hello:

    The first option i think is the best, but i don't have developped
    never a httpHandler, ¿you know any page with a sample?

    For the second option, i think it's too a good solution but if the
    user write in the browser directly the link for the pdf file, the
    broser show a 'Windows Authentication' form, i don't know how to avoid
    this!!

    Thank you Joe, you have put me in the good way.

    On Mon, 11 Apr 2005 23:51:44 GMT, "Yahoo"
    <joe_c_miguel-spam@yahoo.com> wrote:
    >There are two main ways to accomplish this...
    >
    >1) have asp.net protect the file
    >2) have windows ntsf protect the file
    >
    >For 1).
    >You need to have IIS send the requested file to ASP.NET. To accomplish this
    >go into IIS application virtual directory->Home Directory->Mappings.
    >Edit/Add the .pdf to the asp.net frameworks executable path (see .aspx).
    >Uncheck check file exists. Now asp.net will now receive the request. From
    >here you might want to implement a httpHandler and stream the file out.
    >
    >For 2).
    >Create a new role in windows called 'pdfer' or whatever. Set all prfs to be
    >read by this role (and sysem admin and so forth) but not iusr_xxx. When
    >doing form authentication, set the identity of this user to also include
    >this role.
    >
    >Hope that helps
    >Joe
    >
    >"Alessandro Zucchi" <AlessandroZucchi@discussions.microsoft.com> wrote in
    >message news:396D536D-13DA-40A2-93DD-F26DE9C5B795@microsoft.com...
    >> Hi,
    >> I'm developing an asp.net application. I'm using form authentication.
    >> All runs with page aspx, but when I try to connect to a protected file
    >> diverse to an aspx (such as a PDF file) and I'm not authenticated , the
    >> application download the file instead of redirect to the predefined login
    >> page.
    >> Anyone can help me ?
    >>
    >> Best regards
    >> alex
    >>
    >>
    >
    Juan Antonio Tubio 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