Recently encountered a strange error in writing the program: The Response.End () method throws a ThreadAbortException exception, my code is as follows:
Public voidDoresponse () {stringusername=request.params["username"]; stringpassword=request.params["Password"]; Try{ varresult=Bo.dovalidateuserinfo (Username,password); stringmsg=string. Empty; if(result==userloginstatus.error) {msg="User Logon Failure"; }Else if(result==userloginstatus.success) {msg="User Login Successful"; }Else if(...) { ... } Response.writer (msg); Response.End (); }Catch(Excetpion ex) {//Log the error } }
The more depressed is the above code, in the Response.End () place will appear threadabortexception error.
ThreadAbortException can block or block, because ThreadAbortException is a strange anomaly: in. NET it does not throw an exception if it is not captured, but simply terminates the current thread, while other threads continue to run unaffected.
But this is a far-fetched explanation, but the fact is that it is not better to find other answers to explain.
Modify the program to:
Public voidDoresponse () {stringusername=request.params["username"]; stringpassword=request.params["Password"]; Try{ varresult=Bo.dovalidateuserinfo (Username,password); stringmsg=string. Empty; if(result==userloginstatus.error) {msg="User Logon Failure"; }Else if(result==userloginstatus.success) {msg="User Login Successful"; }Else if(...) { ... } Response.writer (msg); }Catch(Excetpion ex) {//Log the error}finally{response.end (); }}
Whatever it is, I hope you can solve your problems.
Response.End throws ThreadAbortException exception