Customerrors in web.config question

R

Ron Weldy

I am working on a website that someone else has set up. They have a
web.config file with a customerrors element that points the error handling
to a special aspx page.

<customErrors mode="RemoteOnly" defaultRedirect="/customerrors/500.aspx">
<error statusCode="404" redirect="/customerrors/404.html" />
</customErrors>

When running pages directly on the server it still redirects when a error
occurs, even though it should not judging by the "RemoteOnly" setting. I
have also tried just setting the mode to "Off" but that does not change the
behavior either. What could I be missing? I have looked for other config
file but have found none. Anybody got any ideas why I cannot turn off the
error handling, or where I can look to figure out what is going on?
 
J

Juan T. Llibre

Are you sure the website is setup as an Application
( or at least as a virtual directory ) in IIS ?

customErrors mode will only work if the web.config
file is placed in the root directory of an IIS application
or in an IIS virtual directory.

The customError settings only apply to ASP.NET files
(files with specific ASP.NET extensions such as aspx and asmx).

If a user requests an .htm or .asp file that does not exist on
your Web server, even if you have the "404" redirect specified
in web.config, IIS will redirect the user based on the HTTP
error settings defined within the IIS metabase and not by the
error settings in the Web.config file.

..asp and .htm files are not managed by ASP.NET.

The ASP.NET Web.config file settings apply to the
application's directory and any child directories.

These settings can be overridden for specific pages using
the ErrorPage attribute of the Page directive.



Juan T. Llibre
ASP.NET MVP
===========
 
R

Ron Weldy

Thanks. I am assuming that the web.config files are not controlling what is
happening but I didn't know where to look. I'll check into your suggestions.
It's script errors that get redirected that I would like to be able to
switch when debugging and then restore after completion. I think this has
been set up as an application and that the config file is in the root, but I
will make sure.

Also, if anyone has a good recommendation on where to read up on the way
this works that would be helpful. I seem to have trouble finding a concise
description on the different levels of error handling in IIS 6 and ASP.NET
and how they interrelate.
 
M

MWells

Ron, if you're trying to disable the custom error handling, then;

+ get rid of the defaultRedirect="" attribute
+ delete the <error /> entity

That should make the custom errors go away.
 
R

Ron Weldy

I tried changing it to <customErrors mode="RemoteOnly"/> and <customErrors
mode="Off"/> but it had no effect at all. I even stopped and restarted the
site.

- Ron
 
G

George

It works depending on the way how you access your site.

Even when you are running locally you need to access it by 127.0.0.1 and not by www.mysite.com (or ip address)

The site would not know how you are accessing it (localy or not) if you are using inet name or ip address


George.

I am working on a website that someone else has set up. They have a
web.config file with a customerrors element that points the error handling
to a special aspx page.

<customErrors mode="RemoteOnly" defaultRedirect="/customerrors/500.aspx">
<error statusCode="404" redirect="/customerrors/404.html" />
</customErrors>

When running pages directly on the server it still redirects when a error
occurs, even though it should not judging by the "RemoteOnly" setting. I
have also tried just setting the mode to "Off" but that does not change the
behavior either. What could I be missing? I have looked for other config
file but have found none. Anybody got any ideas why I cannot turn off the
error handling, or where I can look to figure out what is going on?
 
J

Juan T. Llibre

re:
I even stopped and restarted the site.

That was unneeded. Modifying web.config will restart it for you

re:
it had no effect at all

If you set it to:

<customErrors mode="Off"
</customErrors>

It still shows error pages ?

Also, check global.asax to see if there's
an Error handling configuration there.

( In the Application_Error code block )




Juan T. Llibre
ASP.NET MVP
===========
 
R

Ron Weldy

Really? That has not been my experience. There are several sites on this server and for some it works fine accessing the site from the server using the domain. When I access from the server I get a complete error message and from outside I get the redirect.

It just seems that on this one site that I have problems. At any rate, I plan to look into the points that Juan made so hopefully I can track down the problem. It is odd...

It probably does not help that there is a mixture of asp, aspx, html and other stuff on here.

- Ron

It works depending on the way how you access your site.

Even when you are running locally you need to access it by 127.0.0.1 and not by www.mysite.com (or ip address)

The site would not know how you are accessing it (localy or not) if you are using inet name or ip address


George.

I am working on a website that someone else has set up. They have a
web.config file with a customerrors element that points the error handling
to a special aspx page.

<customErrors mode="RemoteOnly" defaultRedirect="/customerrors/500.aspx">
<error statusCode="404" redirect="/customerrors/404.html" />
</customErrors>

When running pages directly on the server it still redirects when a error
occurs, even though it should not judging by the "RemoteOnly" setting. I
have also tried just setting the mode to "Off" but that does not change the
behavior either. What could I be missing? I have looked for other config
file but have found none. Anybody got any ideas why I cannot turn off the
error handling, or where I can look to figure out what is going on?
 
R

Razvan Petcu

I encountered the same error: after deploying a Web Application on the
production server, I get this generic error page. My problem is how can
I see what is the error exactly, as I have more than one website on that
server ( using host headers). If I copy the application in a virtual
directory under another website on the same server, it works. When I
install or copy it in the root or a virtual directory under the Website
where I want it to be, it doesn't work. Any help will be appreciated.
 
J

Joyjit Mukherjee

Razvan,

It depends what settings you put under the <customerrors mode = ""> tag to
see a specific ASP .NET specific error page instead of an user-defined error
page. Can you elaborate more on this ?

regards
Joyjit
 
R

Razvan Petcu

I figured it out... the NETWORK SERVICE user account did not have any
right on the root folder of the website I was trying to install the web
application in. The checkbox "Allow inheritable permissions from the
parent to propagate to this object..." on the "Advanced Security
Settings for <folder name>"was unchecked. Sorry about this.. I should
have figured it out right away.
However, the question remains: I wasn't able to see the error message
even after setting the mode attribute of customErrors tag in web.config
to "Off". Why is that? And more... suppose I leave this to
"RemoteOnly"... and connect remotely to the server and open an IE window
for "http://localhost/myapp_name/"... it doesn't work..as I have more
than one website on this server (using host headers)... Anyway...
another question would be: how can I access my application locally on
the production server, when it is installed under the root of a website
that uses host headers (note: all the websites use the same IP address)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

customErrors 1
<customErrors 3
encrypted connectionStrings web.config customErrors 2
customerrors tag doesnt works 2
CustomErrors! What is going on? 0
customErrors question 1
customErrors 1
customErrors 0

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top