TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sudipta Saha
NA
85
13.4k
how to solve NullReferenceException exception in Log.Error
Jan 24 2018 2:30 PM
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
Reply
Answers (
2
)
only entering letters/characters into textbox
Whatsapp business with asp.net