我的C#代码就像这样
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;
}
Log.Error(ex); 抛出此 System.NullReferenceException:对象引用未设置为对象实例错误导致var ex = 服务器.GetLastError(); 为空。我的问题是如何解决这个错误?任何信息都会对此有所帮助