Solved

web.config customErrors Not Working

Posted on 2010-11-29
7
746 Views
Last Modified: 2012-05-10
My redirect code in customErrors in web.config has suddeny stopped working.  It probably has to do with updating to asp.net 3.5 from 2.0 last week.  Though I'm not sure how. I didn't notice until today that I am now getting the standard 404 error instead of being redirecting to the .aspx page I specified.

Here is my code in web.config:

    <customErrors mode="On" defaultRedirect="ExceptionPage.aspx">
            <error statusCode="404" redirect="redirect.aspx"/>
    </customErrors>

This all works on my development machine.  It is only broken on the hosted site.

All help is greatly welcomed.

Thanks,
Hunter
0
Comment
Question by:hzuker44
7 Comments
 
LVL 13

Expert Comment

by:themrrobert
ID: 34235856
Check and make sure that 3.5 didn't add any include files to web.config or any code tacked on that may overwrite your settings, this is the most common cause of backward compatibility failure
0
 

Author Comment

by:hzuker44
ID: 34235971
I did look at the differences between the old and new web.config files.  But I really couldn't tell what might affect customErrors this way.

Here are the changes I see:

In the new web.config the following 4 lines were added:

    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

There are a lot of lines were the version was changed to 3.5.  I assume they're OK.
 
And the following code is all new:

<compilers>
    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="WarnAsError" value="false"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="OptionInfer" value="true"/>
    <providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>
    <runtime>
         <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly>
            <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime></configuration>


I'm not smart enough to know if these changes would affect customErrors.    
0
 
LVL 14

Accepted Solution

by:
robasta earned 500 total points
ID: 34237342
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:hzuker44
ID: 34241850
I don't think this is the issue.  I'm getting the error on remote machines.  This article seems to be for Remote Only situations.  

Plus, I didn't change IIS versions, I  changed ASP.NET versions (from 2.0 to 3.5).  It was working before on which ever version of IIS I'm on and now it isn't.  (It's not working on a hosted version of my site so I'm not 100% sur which version of IIS I'm using.)
0
 

Author Comment

by:hzuker44
ID: 34425522
Robasta's answer did not really address my problem.

I think I have found the issue with this.  It looks like URLs with specific extensions (like aspx) get redirected properly.  But I need to redirect everything (normally 404s) via customErrors regardless of the extension.  So I need all types to be mapped to aspnet_isapi.dll.  
 
I found a link that seems to describe this problem:  http://forums.asp.net/t/1521191.aspx  (The relevant part is midway down the discussion posted by Thomas Sun – MSFT ).  He in turn points to a link that has specific directions on what needs to be done in IIS.

I'm not 100% sure that this the issue as I'm having problems with my host company to implement this.  But it seems to explain everything that I see.
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 34429113
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
edit .asp files 5 31
Add or delete table rows 10 54
Need syntax help building hyperlink 2 27
asp Google Map 2 32
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question