enter image description hereI am new to development and I am working on a project to convert the asp.net application to asp.net core. But I am facing a few challenges on the on exception method. I need your assistance and guidance for this cause. The on exception error is thrown as there is not suitable method found over ride. Below is my code.
protected override void OnException(ExceptionContext filterContext)
{
var urlReferrerAbsolutePath = HttpContext.Request.GetDisplayUrl();
var canvasName = urlReferrerAbsolutePath.Split('-').Last();
canvasName = canvasName.Replace("%20", " ");
ec_log log = new ec_log()
{
Date = DateTime.Now.ToUniversalTime(),
ControllerName = filterContext.RouteData.Values["controller"].ToString(),
ActionName = filterContext.RouteData.Values["action"].ToString(),
Type = Share.MESSAGE_TYPE_ERROR,
LogginOn = Share.MESSAGE_TYPE_EXCEPTION,
LoggedInUserId = LoggedInId,
LoggedInUserName = Share.LoggedInMembersFirstName,
Exception = (filterContext.Exception.InnerException != null ?
filterContext.Exception.InnerException.ToString()
: "") + " " + filterContext.Exception.Message,
System = _systemName,
CompanyID = Share.LoggedInMembersCompanyID,
Url = filterContext.HttpContext.Request.GetDisplayUrl(),
CanvasName = canvasName,
StackTrace = filterContext.Exception.StackTrace != null ? filterContext.Exception.StackTrace : ""
};
new LogModel(_configuration).InsertLog(log);
if (filterContext.ExceptionHandled)
{
return;
}
filterContext.Result = new ViewResult
{
ViewName = "~/Views/Shared/Error.aspx"
};
filterContext.ExceptionHandled = true;
}