IIS 7.0 on Windows Server 2008 R1 x64.
The web site runs a mix of ASP.NET 2.0 and 4.0 applications.
The custom 404 page is a 2.0 app.
The web.config file on the root of the site contains this:
I beg your pardon, Martin, but your reply makes very little sense.
I should not need to use a URL rewriter. Configuring IIS to generate custom 404 error pages should be a simple matter that should be possible without a rewriter.
Perhaps you are overanalyzing my problem. For several years, we have been running a web site containing ASP.NET 2.0 application. When you request a file that does not exist, our custom 404 error page, which is also a 2.0 application, appears.
Now, we are adding ASP.NET 4.0 applications to the site.
When you request a file that does not exist and the path is under a 2.0-configured folder (e.g. www.mysite.com/dotnet2app/does_not_exist.html), our custom 404 error page still appears.
When you request a file that does not exist and the path is under a 4.0-configured folder (e.g. www.mysite.com/dotnet4app/does_not_exist.html), the browser window appears blank. If you sniff the low-level HTTP response, the server is reporting a 500 error.
The problem here is that you cannot have the same application pool sharing 2 versions of the .net CLR so you cannot have .net 2 with .net 4
If you have that you will get a http status code 500 app error (I forget the http status subcode but I think there is an event log normally for this). So you have separate app pools for them.
Now I suspect that the error pages be crossing the app pools. So when you have a 4.0 .net app (I presume you have a separate app pool for it) it then calls "The custom 404 page is a 2.0 app." causing the error. A .net 4 app calling a .net 2.0 code all
in the same pool. Crash....
I would just make a copy of 404 page app in .net 4.0 and call that for .net 4.0 apps.
Fancy redirects sound possible but I think over engineering this situation.
you cannot have the same application pool sharing 2 versions of the .net CLR
...
I would just make a copy of 404 page app in .net 4.0 and call that for .net 4.0 apps.
Fancy redirects sound possible but I think over engineering this situation.
I was thinking the same thing. The only thing I could think of that would work is to have 2 custom 404 error pages - one for 2.0 apps and the other for 4.0 apps. But if IIS is able to redirect to a custom 404 error page and it is not overly difficult to
configure, then we could stay with just one error page and not need to main two. If anyone knows if this is possible, please let me know. Otherwise, we will build a second error page.
I need the next step of help on this please. We have built a 404 page in 4.0. So now we have 2 custom 404 pages - 2.0 and 4.0. But we can't figure out how to tell IIS which 404 page to use.
I can see 3 places where error pages are configured:
In IIS manager under the "Error Pages" feature.
In IIS manager under the ".NET Error Pages" feature.
In web.config using the <customErrors> tag.
I have always been a little confused over when these different settings are used. We have just set all 3 to the same thing and it has worked. But now that applications need to use a different custom error page depending on the .NET version, I don't know
where to configure that.
I thought that I could add a <customErrors> tag in the web.config for the 4.0 application, but bad requests still go to the 2.0 error page.
cstobbe
60 Posts
mixed .NET versions using common 404 page
Oct 05, 2011 08:06 PM|LINK
IIS 7.0 on Windows Server 2008 R1 x64.
The web site runs a mix of ASP.NET 2.0 and 4.0 applications.
The custom 404 page is a 2.0 app.
The web.config file on the root of the site contains this:
<customErrors mode="RemoteOnly" defaultRedirect="/error404/index.aspx">
<error statusCode="404" redirect="/error404/index.aspx" />
</customErrors>
When you request a file does not exist under a 4.0 folder (e.g. www.mysite.com/dotnet4app/does_not_exist.html), the web server generates a 500 error.
Can ASP.NET 2.0 and 4.0 share the same custom 404? If yes, how do we properly configure it?
ASP.NET 4.0 404 Handler
HCamper
8048 Posts
Re: mixed .NET versions using common 404 page
Oct 05, 2011 09:56 PM|LINK
Hi,
You have "IIS 7.0 on Windows Server 2008 R1 x64"
and your Task is to Manage missing Web Sites Applications and and files.
Maybe try a different Approach ?
Maybe instead of Custom errors use urlRewrite to receive the requests
and make the decisions.http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/
with Rules and Expressions for Requests and regular expressions for File matches ?
Maybe I am reading the description or questions wrong ?
Feel free to ask questions.
I do suggest try a post in the Rewrite Forum for this suggestion. :D.
Just a suggestion,
Martin
Community Member Award 2011
cstobbe
60 Posts
Re: mixed .NET versions using common 404 page
Oct 06, 2011 09:53 PM|LINK
I beg your pardon, Martin, but your reply makes very little sense.
I should not need to use a URL rewriter. Configuring IIS to generate custom 404 error pages should be a simple matter that should be possible without a rewriter.
Perhaps you are overanalyzing my problem. For several years, we have been running a web site containing ASP.NET 2.0 application. When you request a file that does not exist, our custom 404 error page, which is also a 2.0 application, appears.
Now, we are adding ASP.NET 4.0 applications to the site.
When you request a file that does not exist and the path is under a 2.0-configured folder (e.g. www.mysite.com/dotnet2app/does_not_exist.html), our custom 404 error page still appears.
When you request a file that does not exist and the path is under a 4.0-configured folder (e.g. www.mysite.com/dotnet4app/does_not_exist.html), the browser window appears blank. If you sniff the low-level HTTP response, the server is reporting a 500 error.
Cam
HCamper
8048 Posts
Re: mixed .NET versions using common 404 page
Oct 07, 2011 07:01 PM|LINK
Ok,
You may be correct looking at the question too hard.
I try to use patterns and regular expressions.
Sorry this is a habit from "linux" and "Math".
I try to code less and let the Machine do more with the available tools.
In either case look at the reference again:
Then follow the guide and reference.
Reference for HTTP Errors http://learn.iis.net/page.aspx/267/how-to-use-http-detailed-errors-in-iis-70/
Martin
Community Member Award 2011
cstobbe
60 Posts
Re: mixed .NET versions using common 404 page
Oct 18, 2011 09:27 PM|LINK
This was the information I needed. Basically, 2.0 and 4.0 application cannot share the same custom error page.
How would this work? If someone requests a page that does not exist, how do you configure IIS to redirect?
HCamper
8048 Posts
Re: mixed .NET versions using common 404 page
Oct 18, 2011 10:04 PM|LINK
Hi,
Both items in quotes are the "Security Considerations" part of the guide documentation
that relate to doing the steps for Custom Errors.
And the last one is important since you have different "Application Pools".
Did you read the "execute url" "redirect" suggestions in the guide ?
Martin
Community Member Award 2011
Rovastar
3321 Posts
MVP
Moderator
Re: mixed .NET versions using common 404 page
Oct 19, 2011 12:54 AM|LINK
I think people are looking too hard. ;-)
The problem here is that you cannot have the same application pool sharing 2 versions of the .net CLR so you cannot have .net 2 with .net 4
If you have that you will get a http status code 500 app error (I forget the http status subcode but I think there is an event log normally for this). So you have separate app pools for them.
Now I suspect that the error pages be crossing the app pools. So when you have a 4.0 .net app (I presume you have a separate app pool for it) it then calls "The custom 404 page is a 2.0 app." causing the error. A .net 4 app calling a .net 2.0 code all in the same pool. Crash....
I would just make a copy of 404 page app in .net 4.0 and call that for .net 4.0 apps.
Fancy redirects sound possible but I think over engineering this situation.
cstobbe
60 Posts
Re: mixed .NET versions using common 404 page
Oct 19, 2011 04:03 PM|LINK
I was thinking the same thing. The only thing I could think of that would work is to have 2 custom 404 error pages - one for 2.0 apps and the other for 4.0 apps. But if IIS is able to redirect to a custom 404 error page and it is not overly difficult to configure, then we could stay with just one error page and not need to main two. If anyone knows if this is possible, please let me know. Otherwise, we will build a second error page.
Cam
cstobbe
60 Posts
Re: mixed .NET versions using common 404 page
Oct 20, 2011 04:32 PM|LINK
I need the next step of help on this please. We have built a 404 page in 4.0. So now we have 2 custom 404 pages - 2.0 and 4.0. But we can't figure out how to tell IIS which 404 page to use.
I can see 3 places where error pages are configured:
I have always been a little confused over when these different settings are used. We have just set all 3 to the same thing and it has worked. But now that applications need to use a different custom error page depending on the .NET version, I don't know where to configure that.
I thought that I could add a <customErrors> tag in the web.config for the 4.0 application, but bad requests still go to the 2.0 error page.
Your help and advice is appreciated.
Cam