Hi, Maybe you must add some backend code like this.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Web;
using Umbraco.Core.Models.Membership;
internal static class AuditHelper
{
internal static string RemoteHostName
{
get
{
string hostName = String.Empty;
try
{
hostName = Dns.GetHostEntry(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]).HostName;
}
catch(Exception)
{
hostName = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
return hostName;
}
}
Would you call this method from the Default view or would you attach it the backed to an event?
I don't like editing files that will possibly get overwritten by an update, but I don't know how I can extend this view.
Only every time a request is sent to the back office.
You could probably implement Application_BeginRequest in a class that inherits from UmbracoApplication and that is referenced in your Global.asax. You'd then simply have to look at the beginning of the path to ensure it starts with umbraco.
As long as I don't do the lookup before checking the URL path, performance should be negligible right?
For the frontend of the site, performance should be negligible. I doubt the backend will slow that much (depends on how you do the logging), but if you really want to ensure optimal performance you could do the logging on a background thread.
Umbraco backoffice IP logging
Hi I would like to log server side what IPs are visiting our backoffice URL(s).
What files do I need to edit and insert my own logic? Umbraco/Views/Default.chtml looks like it might be the backoffice "master layout" ?
Thanks, Sean
Hi, Maybe you must add some backend code like this.
Awesome, thanks Martin!
Would you call this method from the Default view or would you attach it the backed to an event? I don't like editing files that will possibly get overwritten by an update, but I don't know how I can extend this view. Only every time a request is sent to the back office.
Put a class in the App code folder.
i.e.: ApplicationEvents.cs
In these class manage funtions or methods to catch
You could probably implement
Application_BeginRequest
in a class that inherits fromUmbracoApplication
and that is referenced in yourGlobal.asax
. You'd then simply have to look at the beginning of the path to ensure it starts withumbraco
.Thanks, I think this is the best option. As long as I don't do the lookup before checking the URL path, performance should be negligible right?
For the frontend of the site, performance should be negligible. I doubt the backend will slow that much (depends on how you do the logging), but if you really want to ensure optimal performance you could do the logging on a background thread.
is working on a reply...