473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

Thanks

Jul 2 '08 #1
6 5634
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...@community.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 UnauthorizedAccessException at that time? I want to pass
an "access denied" back to the browser but am not sure if that will
work.

Thanks
Jul 3 '08 #2

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 <su********@gmail.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...@community.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 UnauthorizedAccessException at that time? I want to pass
an "access denied" back to the browser but am not sure if that will
work.

Thanks
Jul 3 '08 #3
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 <coco...@community.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...@gmail.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...@community.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 UnauthorizedAccessException at that time? I want to pass
an "access denied" back to the browser but am not sure if that will
work.
Thanks
Jul 3 '08 #4
"Norm" <ne*****@gmail.comwrote in message
news:ab**********************************@z32g2000 prh.googlegroups.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.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 )
Jul 6 '08 #5

So throwing an UnauthorizedAccessException is not the same as sending
a 401 in the HTTP Response?
On Sun, 6 Jul 2008 19:18:40 +0100, "Marc " <Rm********@imarc.co.uk>
wrote:
>"Norm" <ne*****@gmail.comwrote in message
news:ab**********************************@z32g200 0prh.googlegroups.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.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 )
Jul 7 '08 #6

If /unauthorized.aspx 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 <ne*****@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.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 <coco...@community.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...@gmail.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...@community.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 UnauthorizedAccessException at that time? I want to pass
an "access denied" back to the browser but am not sure if that will
work.
>Thanks
Jul 7 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Burton Roberts | last post by:
This is also posted in the security newsgroup. Sorry for cross-posting, but I'm desperate. I have a Winforms application in VB.NET with a SQL Server (MSDE) backend. In the root application...
0
by: Efi | last post by:
Hi, We have a simple 3 tier application which its core application is VC++ 6.0 ATL COM running as a server application in the COM+. An asp pipe is in charge of handling the requests and passes it...
7
by: Peter Afonin | last post by:
Hello, I'm using this code to access a network share from an asp.net page: Dim dir As DirectoryInfo = New DirectoryInfo("\\10.0.0.150\FormLib\") Dim files() As FileInfo = dir.GetFiles("*.eps")...
0
by: masago | last post by:
Hi....how are you ?? they can help me to solve this problem ?? Access to the path = "c:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET = Files\reports\06639073\bbab30a7" is...
0
by: nime | last post by:
I've got a problem. I cannot debug my app. which one contains WebBrowser control. I found a resolution but it's for an ASP related problem. I couldn't find a correct "user" to give permisson then...
2
by: job | last post by:
In a sharepoint setup using smartpart to load our user controls using enterprise blocks (data) we are getting some strange errors (logged to the event log). We dont get the error all the time. When...
3
by: BLUE | last post by:
I've created a folder named TestDir in my wwwroot and I've created the associated virtual application from IIS management snap-in. I've given full control to TestDir to: IUSR, ASPNET, Network...
1
by: nygiantswin2005 | last post by:
Hi I am trying to resolve this bug that I have in this application. The code is below. It will generate this Exception System.UnauthorizedAccessException: Access to the path is denied. at...
1
by: JDS | last post by:
I am getting the following error in my application: System.UnauthorizedAccessException was unhandled Message="Access to the port is denied." Source="System" StackTrace: at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.