mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added IP and Referel url to error email
This commit is contained in:
parent
6f208f4d25
commit
8c4be85ba9
@ -47,8 +47,8 @@ namespace Teknik
|
||||
if (routeData == null) return null; // Only look at the subdomain if this route matches in the first place.
|
||||
string subdomain = httpContext.Request.QueryString["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname.
|
||||
string host = httpContext.Request.Headers["Host"];
|
||||
string curSub = host.GetSubdomain();
|
||||
string domain = host.GetDomain();
|
||||
string curSub = host.GetSubdomain();
|
||||
|
||||
// special consideration for 'dev' subdomain
|
||||
if (subdomain == null || subdomain == "dev")
|
||||
|
@ -148,8 +148,10 @@ namespace Teknik.Areas.Error.Controllers
|
||||
Message: {0}
|
||||
|
||||
Source: {1}
|
||||
IP Address: {2}
|
||||
Referer Address: {3}
|
||||
|
||||
Stack Trace: {2}", ex.GetFullMessage(true), ex.Source, ex.StackTrace);
|
||||
Stack Trace: {4}", ex.GetFullMessage(true), ex.Source, GetIPAddress(), Request.UrlReferrer.AbsoluteUri, ex.StackTrace);
|
||||
mail.BodyEncoding = UTF8Encoding.UTF8;
|
||||
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Never;
|
||||
|
||||
@ -157,5 +159,22 @@ Stack Trace: {2}", ex.GetFullMessage(true), ex.Source, ex.StackTrace);
|
||||
}
|
||||
catch (Exception) { /* don't handle something in the handler */ }
|
||||
}
|
||||
|
||||
private string GetIPAddress()
|
||||
{
|
||||
System.Web.HttpContext context = System.Web.HttpContext.Current;
|
||||
string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
|
||||
|
||||
if (!string.IsNullOrEmpty(ipAddress))
|
||||
{
|
||||
string[] addresses = ipAddress.Split(',');
|
||||
if (addresses.Length != 0)
|
||||
{
|
||||
return addresses[0];
|
||||
}
|
||||
}
|
||||
|
||||
return context.Request.ServerVariables["REMOTE_ADDR"];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user