473,472 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Redirect to error page

Hi folks,

I've been searching for this for some time, but all I seem to be able to
find are pages describing how to set custom error pages, whereas what I
want to do is simply redirect the user to a standard error page.

This pseudo-code demonstrates what I want to do:

if (condition) {
Redirect to 403 error;
}
else {
DoSomethingElse();
}

Any ideas how I would accomplish this?

Cheers,

--
Dylan Parry - http://webpageworkshop.co.uk

Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.
Aug 4 '06 #1
1 4670
Hi Dylan,
Your question is a little vague so I've made a couple of assumptions:
namely that you're using ASP.NET 2 hosted in IIS 6. I would hesitate
before trying to write my own security-related code especially in an
internet application; Microsoft provides a lot of this for you inside
IIS and I'd lean towards giving IIS the resposibility of returning 403
Forbidden errors. You can always customise the 403 page to your own
liking by changing your server's configuration. However, if you're dead
keen on rolling your own code, you can use HttpServerUtility.Transfer()
to transfer control to another aspx page. An instance of
HttpServerUtility can be obtained from a System.Web.UI.Page's Server
property. Just don't forget to set the StatusCode property on the
response object of your custom "forbidden" page. Finally, it might be
an idea to centralize your logic: if you throw a new sub type of
Exception to signify that a 403 error page should be displayed, you
could catch this in the Global.asax's Application_Error event handler
(or use the web config's customErrors section).
Cheers,
Jono

Dylan Parry wrote:
Hi folks,

I've been searching for this for some time, but all I seem to be able to
find are pages describing how to set custom error pages, whereas what I
want to do is simply redirect the user to a standard error page.

This pseudo-code demonstrates what I want to do:

if (condition) {
Redirect to 403 error;
}
else {
DoSomethingElse();
}

Any ideas how I would accomplish this?

Cheers,

--
Dylan Parry - http://webpageworkshop.co.uk

Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.
Aug 4 '06 #2

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

Similar topics

1
by: Damo | last post by:
Could someone please help me. I am a newbie at PHP. I downloaded formail.php Version 5.0 from Jacks scripts( http://www.dtheatre.com/scripts/ )and changed the required areas to my email address and...
10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
3
by: Sean Berry | last post by:
Hi there. I am relativly new to Python CGI and need a question answered. I have made custom 404 error pages and have them in various web directories. I have not been able to figure out a way...
6
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx...
2
by: Brian | last post by:
I'm trying to response.redirect to another page on a button click event and I get an error message stating that the thread was being aborted (if I trap for the error that is...) I've researched...
8
by: Andreas Klemt | last post by:
Hello, I get this error Message "cannot redirect after http headers have been sent" when I do this response.redirect ("home.aspx") How can I find out with vb.net if already a http header has...
1
by: Mukund Patel | last post by:
Hi friends, I have implemented custom error handling at page level and application level. If there is any syntax error in my aspx class file it will redirect to error page when I run the page....
1
by: MikeM | last post by:
We are getting a behavior on a Response.Redirect("SomeUrl", True) that I'm hoping someone can explain. This all refers to the code snip at the end. By the way, this is all VB ASP.NET v1.0 code. ...
3
by: wwwmike | last post by:
For some reasons my HTTP Redirect for 404 errors does not work for certain files like .gif .jpg on IIS Version: 5.1, but it works perfectly with the VisualStudio2005 internal webserver ...
7
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I am trying to set this up using asp code and IIS configuration. But it seems not working. Here it is the way I am doing. In IIS I set up a virtual directory with secure communication, I...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.