/// <summary> /// On configured system /// </summary> /// <param name="ctx"></param> /// <param name="next"></param> /// <returns></returns> public static async Task ConfiguredSystem(this HttpContext ctx, Func <Task> next) { try { UrlRewriteHelper.CheckLanguage(ref ctx); await next(); var isClientUrl = await UrlRewriteHelper.ParseClientRequestAsync(ctx); if (isClientUrl) { await next(); } else if (ctx.Response.StatusCode == StatusCodes.Status404NotFound && !ctx.Response.HasStarted) { //Re-execute the request so the user gets the error page var originalPath = ctx.Request.Path.Value; ctx.Items["originalPath"] = originalPath; ctx.Request.Path = "/Handler/NotFound"; await next(); } } catch (Exception e) { Console.WriteLine(e); } }