Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
tools
vsnet.act
vsnet.debugging
vsnet.documentation
vsnet.enterprise.tools
vsnet.general
vsnet.ide
vsnet.jlca
vsnet.servicepacks
vsnet.setup
vsnet.vsip
vsnet.vss
vsnet.vstools.office
vstudio.development
vstudio.extensibility
vstudio.general
vstudio.helpauthoring
vstudio.setup
vstudio.sourcesafe
  
 
date: Tue, 19 Aug 2008 14:48:46 -0500,    group: microsoft.public.vstudio.development        back       


custom errors not working in .net 2005   
I have two problems with custom errors. Both involve code that I've been
using since VS.NET (1.0) but the code now behaves differently in the two new
project that I've created. One project I created was just a single web form
and a couple of html files just to see if there was an issue with the
application that I'm really having the problem with but the problem exists
in both the actual web application and the test web application.

Problem 1: when "Catch ex As Exception" is included in the Try block, the
defaultRedirect page is not displayed like it has done so in the past.
Problem 2: HTTP 404 errors are only handled when using the built-in IIS of
VS.NET 2005. But when using IIS in Windows 2000, the exact same code doesn't
work.

Here is what I have in the web.config file:
<customErrors mode="On" defaultRedirect="ErrorPage.htm">
 <error statusCode="404" redirect="HTMLPage.htm"/>
</customErrors>

Like I said, I've never had this problem before in any of the applications
that I support.

This Try block has always worked until now. Note that I used to not use
customErrors and instead wrote the stack trace error but when I began to use
customErrors, I simply commented out the Response.End() line so that the
error message was never written due to the redirect to the custom error
page:
Try
 SQL = "EXEC sp_DOESNTEXIST"
 cm.CommandText = SQL
 conn.Open()
 cm.ExecuteNonQuery()
Catch ex As Exception
 Response.Write("<br>STACKTRACE:<BR>" & ex.Message & "<br>" & ex.StackTrace)
 ' 'Response.End()
Finally
 If Not conn Is Nothing Then conn.Close()
End Try

Now, I either have to comment out "Catch ex As Exception" or add "Throw"
between "Catch ex As Exception" and "Finally" in order for the custom error
page to be displayed.

The issue with the Try block is not as big of a deal as the issue of
non-handling of 404 error in IIS. I'm not sure how to determine the version
of IIS but it is what came with Windows 2000 Server which I run on my
development computer. This problem is also an issue on our production W2k
Server. Any ideas?

David
date: Tue, 19 Aug 2008 14:48:46 -0500   author:   David Webb strangecargo

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us