Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
In version 8 our third-party web folks implemented this code:
namespace Galbraith.Composers { public class ReapitServiceComposer : IUserComposer { public void Compose(Composition composition) { composition.Register<IReapitService, ReapitService>(Lifetime.Singleton); ServerVariablesParser.Parsing += ServerVariablesParserOnParsing; } private void ServerVariablesParserOnParsing(object sender, Dictionary<string, object> e) { if (HttpContext.Current == null) throw new InvalidOperationException("HttpContext is null."); var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData())); var umbracoUrls = (Dictionary<string, object>)e["umbracoUrls"]; umbracoUrls.Add("reapitImportUrl", urlHelper.GetUmbracoApiServiceBaseUrl<ReapitImportController>(controller => controller.Import(null, false, null, false))); e["umbracoUrls"] = umbracoUrls; } } }
I've managed to convert bits of it, but I do not understand the logic behind the server variables in Umbraco 13.
I've read into the severvariablesparsingnotification but have no idea if it is what I need and I can't seem to work out how to implement it either.
Any pointers are much appreciated!
Hi Sandy,
In version 13 you could do it like this:
Register in for example startup
builder .AddNotificationHandler<ServerVariablesParsingNotification, UmbracoEventListeners>();
Event Listener class
class UmbracoEventListeners : INotificationHandler<ServerVariablesParsingNotification> { public UmbracoEventListeners() { } public void Handle(ServerVariablesParsingNotification notification) { notification.ServerVariables.Add("umbracoUrls", new { reapitImportUrl= "baseUrlOfTheReapitImportController", }); }
Hope this gets you on the right track
Hi Garðar,
I'll give it a shot and see if I can get it to do something :)
Thanks, Sandy
p.s. will report back and mark it as correct if it moves things forward!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco 13 ServerVariablesParsing
Hi,
In version 8 our third-party web folks implemented this code:
I've managed to convert bits of it, but I do not understand the logic behind the server variables in Umbraco 13.
I've read into the severvariablesparsingnotification but have no idea if it is what I need and I can't seem to work out how to implement it either.
Any pointers are much appreciated!
Hi Sandy,
In version 13 you could do it like this:
Register in for example startup
Event Listener class
Hope this gets you on the right track
Hi Garðar,
I'll give it a shot and see if I can get it to do something :)
Thanks, Sandy
p.s. will report back and mark it as correct if it moves things forward!
is working on a reply...