/// <summary> /// Creates a new Umbraco context. /// </summary> /// <param name="httpContext"></param> /// <param name="applicationContext"> </param> /// <param name="routesCache"> </param> internal UmbracoContext( HttpContextBase httpContext, ApplicationContext applicationContext, IRoutesCache routesCache) { if (httpContext == null) throw new ArgumentNullException("httpContext"); if (applicationContext == null) throw new ArgumentNullException("applicationContext"); HttpContext = httpContext; Application = applicationContext; RoutesCache = routesCache; // set the urls... //original request url this.OriginalRequestUrl = httpContext.Request.Url; //cleaned request url this.CleanedUmbracoUrl = UriUtility.UriToUmbraco(this.OriginalRequestUrl); }
/// <summary> /// Creates a new Umbraco context. /// </summary> /// <param name="httpContext"></param> /// <param name="applicationContext"> </param> /// <param name="routesCache"> </param> internal UmbracoContext( HttpContextBase httpContext, ApplicationContext applicationContext, IRoutesCache routesCache) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } if (applicationContext == null) { throw new ArgumentNullException("applicationContext"); } ObjectCreated = DateTime.Now; UmbracoRequestId = Guid.NewGuid(); HttpContext = httpContext; Application = applicationContext; RoutesCache = routesCache; // set the urls... //original request url //NOTE: The request will not be available during app startup so we can only set this to an absolute URL of localhost, this // is a work around to being able to access the UmbracoContext during application startup and this will also ensure that people // 'could' still generate URLs during startup BUT any domain driven URL generation will not work because it is NOT possible to get // the current domain during application startup. // see: http://issues.umbraco.org/issue/U4-1890 var requestUrl = new Uri("http://localhost"); var request = GetRequestFromContext(); if (request != null) { requestUrl = request.Url; } this.OriginalRequestUrl = requestUrl; //cleaned request url this.CleanedUmbracoUrl = UriUtility.UriToUmbraco(this.OriginalRequestUrl); }
/// <summary> /// Creates a new Umbraco context. /// </summary> /// <param name="httpContext"></param> /// <param name="applicationContext"> </param> /// <param name="routesCache"> </param> internal UmbracoContext( HttpContextBase httpContext, ApplicationContext applicationContext, IRoutesCache routesCache) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } if (applicationContext == null) { throw new ArgumentNullException("applicationContext"); } HttpContext = httpContext; Application = applicationContext; RoutesCache = routesCache; // set the urls... //original request url this.OriginalRequestUrl = httpContext.Request.Url; //cleaned request url this.CleanedUmbracoUrl = UriUtility.UriToUmbraco(this.OriginalRequestUrl); }
/// <summary> /// Creates a new Umbraco context. /// </summary> /// <param name="httpContext"></param> /// <param name="applicationContext"> </param> /// <param name="routesCache"> </param> internal UmbracoContext( HttpContextBase httpContext, ApplicationContext applicationContext, IRoutesCache routesCache) { if (httpContext == null) throw new ArgumentNullException("httpContext"); if (applicationContext == null) throw new ArgumentNullException("applicationContext"); ObjectCreated = DateTime.Now; UmbracoRequestId = Guid.NewGuid(); HttpContext = httpContext; Application = applicationContext; RoutesCache = routesCache; // set the urls... //original request url //NOTE: The request will not be available during app startup so we can only set this to an absolute URL of localhost, this // is a work around to being able to access the UmbracoContext during application startup and this will also ensure that people // 'could' still generate URLs during startup BUT any domain driven URL generation will not work because it is NOT possible to get // the current domain during application startup. // see: http://issues.umbraco.org/issue/U4-1890 var requestUrl = new Uri("http://localhost"); var request = GetRequestFromContext(); if (request != null) { requestUrl = request.Url; } this.OriginalRequestUrl = requestUrl; //cleaned request url this.CleanedUmbracoUrl = UriUtility.UriToUmbraco(this.OriginalRequestUrl); }