asp error handling

R

Rob

I have the following code that works well when I run it on localhost,
but when I browse to it from another computer i get the error message
below.

Dim objUser As New DirectoryEntry("LDAP://cn=myName,ou=Tech
Support,dc=mydomain,dc=com")
Try
objUser.Invoke("ChangePassword", Oldpass.Text,
newpass.Text)
objUser.CommitChanges()
Catch ex As Exception
Response.Write(ex.InnerException.Message)
End Try

Here's the error I Get. It's like ex is no longer exposed. What can I
do to handle different types of errors if I cannot use ex?

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error:


Line 35: objUser.CommitChanges()
Line 36: Catch ex As Exception
Line 37: Response.Write(ex.InnerException.Message)
Line 38: End Try
Line 39:


Source File: C:\Inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb
Line: 37

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an
object.]
WebApplication3.WebForm1.Button1_Click(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\WebApplication3\WebForm1.aspx.vb:37
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1277
 
G

Guest

Rob,

First off you're providing unecessary details to the public about your
passwords. Security best practice for passwords is to write the same error
message no matter what the error is. response.write("Sorry, A problem
occured please try again later.")

Your error was in design not all errors have innerexception or
innerexception.message property initialized

Good Luck
DWS
 

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

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top