473,503 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forbidden - how?

Hi,

in one of my pages I want to return "403 Forbidden" to the client depending
on some logic in my .aspx code-behind. So I set "Response.Status = 403". But
apparently IE seems to ignore the status and displays the page as usual.

When I cancel the output using Response.End(), nothing is displayed on the
browser, but actually what I'm expecting is this usual white page showing
the "Forbidden ask your administrator..." text.

What did I do wrong?

TIA,
Axel Dahmen
Dec 7 '05 #1
6 2062
You might make this change directly in IIS. Go to the Custom Errors tab on
the Properties dialog for IIS. Note that IIS will always process website
errors like 403s and 404s first before using any methods within your
application.

One suggestion would be to replace the HTML files used within IIS with your
own ASPX files so you can control your own error messages.

Hope this helps!
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
Hi,

in one of my pages I want to return "403 Forbidden" to the client
depending
on some logic in my .aspx code-behind. So I set "Response.Status = 403".
But
apparently IE seems to ignore the status and displays the page as usual.

When I cancel the output using Response.End(), nothing is displayed on the
browser, but actually what I'm expecting is this usual white page showing
the "Forbidden ask your administrator..." text.

What did I do wrong?

TIA,
Axel Dahmen

Dec 7 '05 #2
You might make this change directly in IIS. Go to the Custom Errors tab on
the Properties dialog for IIS. Note that IIS will always process website
errors like 403s and 404s first before using any methods within your
application.

One suggestion would be to replace the HTML files used within IIS with your
own ASPX files so you can control your own error messages.

Hope this helps!
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
Hi,

in one of my pages I want to return "403 Forbidden" to the client
depending
on some logic in my .aspx code-behind. So I set "Response.Status = 403".
But
apparently IE seems to ignore the status and displays the page as usual.

When I cancel the output using Response.End(), nothing is displayed on the
browser, but actually what I'm expecting is this usual white page showing
the "Forbidden ask your administrator..." text.

What did I do wrong?

TIA,
Axel Dahmen


Dec 7 '05 #3
Hi Axel,

You can throw an HttpException providing the status code.

Best,
--
Daniel Fisher(lennybacon)
http://www.lennybacon.com
"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
Hi,

in one of my pages I want to return "403 Forbidden" to the client
depending
on some logic in my .aspx code-behind. So I set "Response.Status = 403".
But
apparently IE seems to ignore the status and displays the page as usual.

When I cancel the output using Response.End(), nothing is displayed on the
browser, but actually what I'm expecting is this usual white page showing
the "Forbidden ask your administrator..." text.

What did I do wrong?

TIA,
Axel Dahmen

Dec 7 '05 #4
By the time the page gets to ASP.Net, it's too late to have IIS map the
request to the default 403 forbidden page (the page displayed to the browser
is an actual page on the server)

You can see this by going into IIS and seeing the Custom Errors tab. On
solution is to simply output the html you want. Response.Write("<h2>Go
Away</h2>");Response.End();

or you might be able to use the <error> element of the web.config:
http://msdn.microsoft.com/library/de...gngrferror.asp

Not sure if this later trick will work.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
Hi,

in one of my pages I want to return "403 Forbidden" to the client
depending
on some logic in my .aspx code-behind. So I set "Response.Status = 403".
But
apparently IE seems to ignore the status and displays the page as usual.

When I cancel the output using Response.End(), nothing is displayed on the
browser, but actually what I'm expecting is this usual white page showing
the "Forbidden ask your administrator..." text.

What did I do wrong?

TIA,
Axel Dahmen

Dec 7 '05 #5
Thanks, guys, for your valuable help! Actually until now I believed that
this page was generated by the browser somehow. I'm running a German W2K/IIS
so the 403.htm will always appear in German - well, or I would have to go
through the effort in translating the page myself... :(

Just for curiosity: What's the status code good for if the webserver can
send any content it likes anyway?

TIA,
Axel Dahmen

------------------
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2******************@TK2MSFTNGP14.phx.gbl...
By the time the page gets to ASP.Net, it's too late to have IIS map the
request to the default 403 forbidden page (the page displayed to the browser is an actual page on the server)

You can see this by going into IIS and seeing the Custom Errors tab. On
solution is to simply output the html you want. Response.Write("<h2>Go
Away</h2>");Response.End();

or you might be able to use the <error> element of the web.config:
http://msdn.microsoft.com/library/de...gngrferror.asp
Not sure if this later trick will work.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
Hi,

in one of my pages I want to return "403 Forbidden" to the client
depending
on some logic in my .aspx code-behind. So I set "Response.Status = 403".
But
apparently IE seems to ignore the status and displays the page as usual.

When I cancel the output using Response.End(), nothing is displayed on the browser, but actually what I'm expecting is this usual white page showing the "Forbidden ask your administrator..." text.

What did I do wrong?

TIA,
Axel Dahmen


Dec 8 '05 #6
There are some status codes that force the browser to behave, such as 302
(redirect). You'd have to read the HTTP RFC to figure out your answer in
greater detail.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote in message
news:OT******************@tk2msftngp13.phx.gbl...
Thanks, guys, for your valuable help! Actually until now I believed that
this page was generated by the browser somehow. I'm running a German
W2K/IIS
so the 403.htm will always appear in German - well, or I would have to go
through the effort in translating the page myself... :(

Just for curiosity: What's the status code good for if the webserver can
send any content it likes anyway?

TIA,
Axel Dahmen

------------------
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2******************@TK2MSFTNGP14.phx.gbl...
By the time the page gets to ASP.Net, it's too late to have IIS map the
request to the default 403 forbidden page (the page displayed to the

browser
is an actual page on the server)

You can see this by going into IIS and seeing the Custom Errors tab. On
solution is to simply output the html you want. Response.Write("<h2>Go
Away</h2>");Response.End();

or you might be able to use the <error> element of the web.config:

http://msdn.microsoft.com/library/de...gngrferror.asp

Not sure if this later trick will work.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> in one of my pages I want to return "403 Forbidden" to the client
> depending
> on some logic in my .aspx code-behind. So I set "Response.Status =
> 403".
> But
> apparently IE seems to ignore the status and displays the page as
> usual.
>
> When I cancel the output using Response.End(), nothing is displayed on the > browser, but actually what I'm expecting is this usual white page showing > the "Forbidden ask your administrator..." text.
>
> What did I do wrong?
>
> TIA,
> Axel Dahmen
>
>



Dec 8 '05 #7

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

Similar topics

0
6353
by: Oleg Konovalov | last post by:
Hi, I am trying to create 2 separate environments (dev and test) on one powerful Unix server which has 2 network cards, 2 IP addresses, 2 server names... Using Apache 2.0.43 and Tomcat...
0
2108
by: Layne L via DotNetMonster.com | last post by:
Trying to install a .NET application on a Windows 2003 Server ( .NET v1.1) and for any . aspx file get the following error: 403.1 Forbidden: Execute Access Forbidden The application has...
1
6807
by: DotNetter | last post by:
I have two computers. Both computers have Windows 2003 installed as well as Visual Studio.Net 2003 installed. Computer A has active directory set and also has .Net and the webservice called...
4
4209
by: Ollie | last post by:
I have wrriten a reverse proxy for a client of mine, this reverse proxy takes the url takes it attempt to access a *.XXXX and returns the the contents of an aspx web page from another internal...
2
11194
by: Edward Low | last post by:
Hi all, When creating a virtual directory in IIS 5.0 win xp Pro with the name like "abc.com", an error HTTP 403.1 Forbidden: Execute Access Forbidden will return when accessing the web page. But,...
0
7287
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
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5594
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,...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4688
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
3177
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
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
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
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.