Throw System.UnauthorizedAccessException ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • coconet

    Throw System.UnauthorizedAccessException ?


    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 UnauthorizedAcc essException at that time? I want to pass
    an "access denied" back to the browser but am not sure if that will
    work.

    Thanks

  • Anoj

    #2
    Re: Throw System.Unauthor izedAccessExcep tion ?

    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 <coco...@commun ity.nospamwrote :
    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 UnauthorizedAcc essException at that time? I want to pass
    an "access denied" back to the browser but am not sure if that will
    work.
    >
    Thanks

    Comment

    • coconet

      #3
      Re: Throw System.Unauthor izedAccessExcep tion ?


      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 <sutradhaar@gma il.com>
      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 <coco...@commun ity.nospamwrote :
      >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 UnauthorizedAcc essException at that time? I want to pass
      >an "access denied" back to the browser but am not sure if that will
      >work.
      >>
      >Thanks

      Comment

      • Norm

        #4
        Re: Throw System.Unauthor izedAccessExcep tion ?

        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.Status Code = 302
        Response.Status = "302 Moved Temporarily"
        Response.AddHea der("Location", "/Unauthorized.as px") ' Note: "/
        Unauthorized.as px" is just an example
        Response.End()

        Hope this helps.

        On Jul 3, 10:49 am, coconet <coco...@commun ity.nospamwrote :
        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 <sutradh...@gma il.com>
        wrote:
        >
        Another idea could be redirecting the user to a custom page showing
        access denied message.
        >>
        On Jul 3, 1:01 am, coconet <coco...@commun ity.nospamwrote :
        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 UnauthorizedAcc essException at that time? I want to pass
        an "access denied" back to the browser but am not sure if that will
        work.
        >
        Thanks

        Comment

        • Marc

          #5
          Re: Throw System.Unauthor izedAccessExcep tion ?

          "Norm" <neonorm@gmail. comwrote in message
          news:aba5076c-335f-45ca-8490-2a09d1d43785@z3 2g2000prh.googl egroups.com...
          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.Status Code = 302
          Response.Status = "302 Moved Temporarily"
          Response.AddHea der("Location", "/Unauthorized.as px") ' Note: "/
          Unauthorized.as px" 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 )


          Comment

          • coconet

            #6
            Re: Throw System.Unauthor izedAccessExcep tion ?


            So throwing an UnauthorizedAcc essException is not the same as sending
            a 401 in the HTTP Response?


            On Sun, 6 Jul 2008 19:18:40 +0100, "Marc " <RmEaMrOcVE@ima rc.co.uk>
            wrote:
            >"Norm" <neonorm@gmail. comwrote in message
            >news:aba5076 c-335f-45ca-8490-2a09d1d43785@z3 2g2000prh.googl egroups.com...
            >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.Statu sCode = 302
            >Response.Statu s = "302 Moved Temporarily"
            >Response.AddHe ader("Location" , "/Unauthorized.as px") ' Note: "/
            >Unauthorized.a spx" 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 )
            >

            Comment

            • coconet

              #7
              Re: Throw System.Unauthor izedAccessExcep tion ?


              If /unauthorized.as px does not exist, then body content will be sent
              to the browser "page not found" or something. And if it does exist,
              body content will still be sent to the browser. Is there a way to make
              the client hang in a suspended state forever to keep a bot from ever
              getting anything substantial from the server? What do you think of
              activating one of the HTTP authentication schemes to put up a logon
              box, that would make the bots go away and people too.



              On Thu, 3 Jul 2008 12:27:59 -0700 (PDT), Norm <neonorm@gmail. com>
              wrote:
              >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.Statu sCode = 302
              >Response.Statu s = "302 Moved Temporarily"
              >Response.AddHe ader("Location" , "/Unauthorized.as px") ' Note: "/
              >Unauthorized.a spx" is just an example
              >Response.End ()
              >
              >Hope this helps.
              >
              >On Jul 3, 10:49 am, coconet <coco...@commun ity.nospamwrote :
              >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
              >communicatio n process, low level. Can I do that from within a ASPX
              >page?
              >>
              >On Wed, 2 Jul 2008 20:51:29 -0700 (PDT), Anoj <sutradh...@gma il.com>
              >wrote:
              >>
              >Another idea could be redirecting the user to a custom page showing
              >access denied message.
              >>>>
              >On Jul 3, 1:01 am, coconet <coco...@commun ity.nospamwrote :
              >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 UnauthorizedAcc essException at that time? I want to pass
              >an "access denied" back to the browser but am not sure if that will
              >work.
              >>
              >Thanks

              Comment

              Working...