0
我在IIS8.5上有自定义错误页面。有时错误页面本身会引发异常:asp.net自定义错误页面不起作用
未将对象引用设置为对象的实例。
这背后是我的代码部分:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
HttpContext.Current.Response.StatusCode = 500
'Dim CurrentException As Exception = Server.GetLastError()
'virheettxt.text = CurrentException.Message
Dim hostName = System.Net.Dns.GetHostName()
Dim ctxOBJ As HttpContext
Dim exceptionOBJ As Exception
Dim errorInfoTXT As String
ctxOBJ = HttpContext.Current()
exceptionOBJ = ctxOBJ.Server.GetLastError()
errorInfoTXT = " <br>Offending URL: " & iif(Not ctxOBJ Is Nothing, ctxOBJ.Request.Url.ToString(), "ei saatavilla") &
"<br>Source: " & iif(Not exceptionOBJ Is Nothing, exceptionOBJ.Source.ToString(), "ei saatavilla") &
"<br>Message: " & iif(Not exceptionOBJ Is Nothing, exceptionOBJ.Message.ToString(), "ei saatavilla") &
"<br>Stack trace: " & iif(Not exceptionOBJ Is Nothing, exceptionOBJ.StackTrace.ToString(), "ei saatavilla") &
"<br>Target Site: " & iif(Not exceptionOBJ Is Nothing, exceptionOBJ.TargetSite.ToString(), "ei saatavilla") &
"<br>Server: " & hostName
Dim virheurlsc = ctxOBJ.Request.Url.ToString()
ctxOBJ.Server.ClearError()
错误来自行:errorInfoTXT =“
犯规网址:......
,如果有办法捕获错误行在某些情况下,我真的也需要它...?
请参阅[将行号添加到在发布模式下部署的ASP.NET网站的堆栈跟踪](http://stackoverflow.com/a/20069668/1115360),以获得第二个问题。 –
我该怎么做? – Timo77
我认为我提到的答案告诉你。 –