-
Notifications
You must be signed in to change notification settings - Fork 1
/
UmbStartup.cs
34 lines (30 loc) · 1.22 KB
/
UmbStartup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Umbraco.Core;
using Umbraco.Web;
using Umbraco.Web.UI.JavaScript;
namespace Our.DocumentTypeUsage
{
public class UmbStartup : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ServerVariablesParser.Parsing += ServerVariablesParser_Parsing;
}
void ServerVariablesParser_Parsing(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()));
//init cache
var odtu = new OurDocumentTypeUsageApiController();
odtu.Get();
e.Add("ourDocumentTypeUsage", new Dictionary<string, object>
{
{"ourDocumentTypeUsageApiPathGet", urlHelper.GetUmbracoApiServiceBaseUrl<OurDocumentTypeUsageApiController>(contr => contr.Get()) + "Get"}
});
}
}
}