public AdminkaCrudRoutinePageConsumer(PageModel pageModel, Referrer referrer, PageRoutineFeature pageRoutineFeature, Func <User, UserContext> createUserContext, ApplicationSettings applicationSettings, IMemoryCache memoryCache, MemberTag memberTag) : base(pageModel, pageRoutineFeature, getUserAndFailedActionResultInitialisedAsync: (aspRoutineFeature) => AspNetCoreManager.GetUserAndFailedActionResultInitialisedAsync( applicationSettings, memberTag, pageModel, aspRoutineFeature, memoryCache, pageRoutineFeature), getContainerHandler: (aspRoutineFeature, getInput, user, containerFactory) => { var userContext = createUserContext(user); return(MvcAppManager.GetContainerStorageHandler( containerFactory, memberTag, aspRoutineFeature, getInput, userContext, applicationSettings, uc => uc.AuditStamp )); }) { this.Referrer = referrer; }
public AdminkaCrudRoutinePageConsumer( PageModel pageModel, Referrer referrer, [CallerMemberName] string member = null) : this(pageModel, referrer, AspNetCoreManager.SetAndGetPageRoutineFeature(pageModel, referrer), u => MvcAppManager.SetAndGetUserContext(pageModel, u), (ApplicationSettings)pageModel.HttpContext.RequestServices.GetService(typeof(ApplicationSettings)), (IMemoryCache)pageModel.HttpContext.RequestServices.GetService(typeof(IMemoryCache)), new MemberTag(pageModel.GetType().Namespace, pageModel.GetType().Name, member)) { }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env /*, ILoggerFactory loggerFactory, IServiceCollection services*/) { if (env.IsDevelopment()) { //app.UseBrowserLink(); // supports webpack real time server //app.UseMiddleware<DevProxyMiddleware>(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } if (applicationSettings.UseStandardDeveloperErrorPage) { app.UseDeveloperExceptionPage(); // FYI: DatabaseErrorPageExtensions from Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore assembly //DatabaseErrorPageExtensions.UseDatabaseErrorPage(app); } else { const string errorPath = "/Error"; // NOTE: "/Home/Error" for MVC app.UseExceptionHandler(errorPath); //app.UseStatusCodePages((statusCodeContext)=> { // statusCodeContext.HttpContext // return Task.CompletedTask; //}); //app.UseStatusCodePagesWithReExecute("/Error"); app.Use(async(context, next) => { if (context.Request.Path == errorPath) { var ex = context.Features.Get <IExceptionHandlerFeature>().Error; var originalFeature = context.Features.Get <IExceptionHandlerPathFeature>(); if (originalFeature != null && originalFeature.Path != null && originalFeature.Path.Contains("Api/", StringComparison.Ordinal)) // TODO: regex { context.Response.ContentType = "application/json"; var aspRequestId = System.Diagnostics.Activity.Current?.Id ?? context.TraceIdentifier; await context.Response .WriteAsync(MvcAppManager.GetErrorActionJson(ex, aspRequestId, applicationSettings.ForceDetailsOnCustomErrorPage)); // about ConfigureAwait read there https://stackoverflow.com/questions/13489065/best-practice-to-call-configureawait-for-all-server-side-code return; } } // Request.Path is not for /Error *or* this isn't an API call. await next(); }); } app.UseHttpsRedirection(); app.UseStaticFiles(); // TODO: know details ASP CORE 3 app.UseRouting(); //app.UseAuthorization(); //app.UseCookiePolicy(); //app.UseSession(); //app.UseMiddleware<DurationMiddleware>("X-AdminkaV1-Duration-MSec"); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); //NOTE: for MVC //TODO: how to configure area //endpoints.MapControllerRoute( // name: "default", // pattern: "{controller=Home}/{action=Index}/{id?}"); }); // legacy, important because there is area in the template //app.UseMvc(routes => //{ // routes.MapRoute( // name: "defaultArea", // template: "{area:exists}/{controller}/{action}"); //}); }