/// <summary> /// Returns true if the request is for a client side extension /// </summary> public static bool IsClientSideRequest(this HttpRequest request) { PathString absPath = request.Path; UmbracoRequestPaths umbReqPaths = request.HttpContext.RequestServices.GetService <UmbracoRequestPaths>(); return(umbReqPaths.IsClientSideRequest(absPath)); }
public void Is_Client_Side_Request(string url, bool assert) { IHostingEnvironment hostingEnvironment = CreateHostingEnvironment(); var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment); var uri = new Uri("http://test.com" + url); var result = umbracoRequestPaths.IsClientSideRequest(uri.AbsolutePath); Assert.AreEqual(assert, result); }
public void Is_Client_Side_Request_InvalidPath_ReturnFalse() { IHostingEnvironment hostingEnvironment = CreateHostingEnvironment(); var umbracoRequestPaths = new UmbracoRequestPaths(Options.Create(_globalSettings), hostingEnvironment); // This URL is invalid. Default to false when the extension cannot be determined var uri = new Uri("http://test.com/installing-modules+foobar+\"yipee\""); var result = umbracoRequestPaths.IsClientSideRequest(uri.AbsolutePath); Assert.AreEqual(false, result); }
/// <summary> /// Explicitly implement this so that we filter the request /// </summary> /// <inheritdoc /> string?ICookieManager.GetRequestCookie(HttpContext context, string key) { PathString absPath = context.Request.Path; if (!_umbracoContextAccessor.TryGetUmbracoContext(out _) || _umbracoRequestPaths.IsClientSideRequest(absPath)) { return(null); } return(ShouldAuthenticateRequest(absPath) == false // Don't auth request, don't return a cookie ? null // Return the default implementation : GetRequestCookie(context, key)); }