Re: Throw System.UnauthorizedAccessException ?

Discussion in 'ASP .Net' started by Anoj, Jul 3, 2008.

  1. Anoj

    Anoj Guest

    Another idea could be redirecting the user to a custom page showing
    access denied message.

    /Anoj
    [ www.TheTechHub.com ]



    On Jul 3, 1:01 am, coconet <> wrote:
    > I want to block access to my ASP.NET 2.0 web page if the time is
    > between 3:00 and 4:00. I know how to do the date math - is it proper
    > to throw an UnauthorizedAccessException at that time? I want to pass
    > an "access denied" back to the browser but am not sure if that will
    > work.
    >
    > Thanks
     
    Anoj, Jul 3, 2008
    #1
    1. Advertising

  2. Anoj

    Norm Guest

    I would actually suggest against sending a 403 or some other HTTP
    access denied because the crawlers may act adversly. The redirection
    is a good idea. The crawlers will not care as long as it is a
    temporary redirect, not a permanent one. Try something like this:

    Response.StatusCode = 302
    Response.Status = "302 Moved Temporarily"
    Response.AddHeader("Location", "/Unauthorized.aspx") ' Note: "/
    Unauthorized.aspx" is just an example
    Response.End()

    Hope this helps.

    On Jul 3, 10:49 am, coconet <> wrote:
    > I don't want to do that because a crawling bot might be hitting the
    > page too. I want to show unauthorized access early in the HTTP
    > communication process, low level. Can I do that from within a ASPX
    > page?
    >
    > On Wed, 2 Jul 2008 20:51:29 -0700 (PDT), Anoj <>
    > wrote:
    >
    > >Another idea could be redirecting the user to a custom page showing
    > >access denied message.

    >
    > >/Anoj
    > >[www.TheTechHub.com]

    >
    > >On Jul 3, 1:01 am, coconet <> wrote:
    > >> I want to block access to my ASP.NET 2.0 web page if the time is
    > >> between 3:00 and 4:00. I know how to do the date math - is it proper
    > >> to throw an UnauthorizedAccessException at that time? I want to pass
    > >> an "access denied" back to the browser but am not sure if that will
    > >> work.

    >
    > >> Thanks
     
    Norm, Jul 3, 2008
    #2
    1. Advertising

  3. Anoj

    Marc Guest

    "Norm" <> wrote in message
    news:...
    I would actually suggest against sending a 403 or some other HTTP
    access denied because the crawlers may act adversly. The redirection
    is a good idea. The crawlers will not care as long as it is a
    temporary redirect, not a permanent one. Try something like this:

    Response.StatusCode = 302
    Response.Status = "302 Moved Temporarily"
    Response.AddHeader("Location", "/Unauthorized.aspx") ' Note: "/
    Unauthorized.aspx" is just an example
    Response.End()

    Surley HTTP Status 401 Unauthorized would be better, along with response.end
    (no redirect, the browser will just say unauthorized )
     
    Marc, Jul 6, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S. Justin Gengo
    Replies:
    0
    Views:
    888
    S. Justin Gengo
    Jul 14, 2003
  2. Salim Afþar
    Replies:
    0
    Views:
    453
    Salim Afþar
    Aug 11, 2003
  3. Kerri
    Replies:
    2
    Views:
    13,116
    Kevin Spencer
    Oct 27, 2003
  4. Replies:
    15
    Views:
    7,760
    Roedy Green
    Sep 8, 2005
  5. Emanuele D'Arrigo

    To throw or to throw not?

    Emanuele D'Arrigo, Nov 14, 2008, in forum: Python
    Replies:
    6
    Views:
    349
    Emanuele D'Arrigo
    Nov 15, 2008
Loading...

Share This Page