本文整理汇总了C#中System.Web.HttpException.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# HttpException.ToString方法的具体用法?C# HttpException.ToString怎么用?C# HttpException.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpException
的用法示例。
在下文中一共展示了HttpException.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogException
public static void LogException(HttpException exception)
{
if (exception != null)
{
Debug.Print(exception.ToString());
Logger.Error(exception.ToString());
try
{
var error = new VLogServerSideError(exception);
VLogErrorCode weberrorcode = VLog.GetWebErrorCodeOrDefault(error.ErrorCode, VLogErrorTypes.ServerSideIIS);
if (weberrorcode != null && !weberrorcode.ExcludeFromLogging)
{
if (VLog.OnCommitExceptionToServerRepository != null)
{
VLog.OnCommitExceptionToServerRepository(error);
}
}
}
catch (Exception ex)
{
// IMPORTANT! We swallow any exception raised during the
// logging and send them out to the trace . The idea
// here is that logging of exceptions by itself should not
// be critical to the overall operation of the application.
// The bad thing is that we catch ANY kind of exception,
// even system ones and potentially let them slip by.
Logger.Error(ex.ToString());
Debug.Print(ex.Message);
}
}
}
示例2: Application_Error
protected void Application_Error()
{
// Log ASP.NET errors (404, 500)
HttpException exception = new HttpException(null, HttpContext.Current.Server.GetLastError());
Log.Error("An ASP.NET based error occurred - ({0}) - {1}",
exception.GetHttpCode(),
exception.ToString());
}
示例3: ResourceErrorActionResult
/// <summary>
/// Sends back a response using the status code in the HttpException.
/// The response body contains a details serialized in the responseFormat.
/// If the HttpException.Data has a key named "details", its value is used as the response body.
/// If there is no such key, HttpException.ToString() is used as the response body.
/// </summary>
/// <param name="httpException"></param>
/// <param name="responseFormat"></param>
public ResourceErrorActionResult(HttpException httpException, ContentType responseFormat) {
this.statusCode = (HttpStatusCode)httpException.GetHttpCode();
this.details = httpException.Data.Contains("details") ? httpException.Data["details"] : httpException.ToString();
this.responseFormat = responseFormat;
}