Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
how to solve NullReferenceException exception in Log.Error
Sudipta Saha
Jan 24 2018 2:30 PM
170
Reply
My C# code is like this
protected
void
Application_Error(
object
sender, EventArgs e)
{
var ex = Server.GetLastError();
Log.Error(ex);
var httpStatusCode = (ex
is
HttpException) ? (ex
as
HttpException).GetHttpCode() : 500;
var httpContext = ((MvcApplication)sender).Context;
httpContext.ClearError();
httpContext.Response.Clear();
httpContext.Response.StatusCode = httpStatusCode;
var shouldHandleException =
true
;
Exception exceptionToReplace;
}
And Log.Error(ex); throws this
System.NullReferenceException: Object reference not set to an instance of an object
error cause var ex = Server.GetLastError(); is null .
My question is how to solve this error?Any info will be helpful regarding this
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
only entering letters/characters into textbox
Whatsapp business with asp.net