// This method gets called by the runtime. Use this method to testconfigure the HTTP request pipeline.
 public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app)
 {
     app.UseStaticFiles();
     app.UseDefaultFiles();
 }
Exemple #2
0
        } // End Sub ConfigureServices

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            Microsoft.AspNetCore.Builder.IApplicationBuilder app
            , Microsoft.AspNetCore.Hosting.IWebHostEnvironment env
            , Microsoft.Extensions.Logging.ILoggerFactory loggerFactory)
        {
            // https://gunnarpeipman.com/aspnet-core-syslog/
            // https://stackoverflow.com/questions/20951667/how-to-write-to-kiwi-syslog-server-log-c-
            // https://github.com/emertechie/SyslogNet/tree/master/SyslogNet.Client/Transport
            // https://maxbelkov.github.io/visualsyslog/
            loggerFactory.AddSyslog("192.168.210.56", 514);


            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedFor
                                   | Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedProto
            });



            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();


            app.UseDefaultFiles(
                new Microsoft.AspNetCore.Builder.DefaultFilesOptions()
            {
                DefaultFileNames = new System.Collections.Generic.List <string>()
                {
                    "index.htm", "index.html"
                }
            }
                );


            app.UseStaticFiles(
                new Microsoft.AspNetCore.Builder.StaticFileOptions()
            {
                ServeUnknownFileTypes = true,
                DefaultContentType    = "application/octet-stream",
                ContentTypeProvider   = new ExtensionContentTypeProvider(),

                OnPrepareResponse = delegate(Microsoft.AspNetCore.StaticFiles.StaticFileResponseContext context)
                {
                    // https://stackoverflow.com/questions/49547/how-do-we-control-web-page-caching-across-all-browsers

                    // The Cache-Control is per the HTTP 1.1 spec for clients and proxies
                    // If you don't care about IE6, then you could omit Cache-Control: no-cache.
                    // (some browsers observe no-store and some observe must-revalidate)
                    context.Context.Response.Headers["Cache-Control"] = "no-cache, no-store, must-revalidate, max-age=0";
                    // Other Cache-Control parameters such as max-age are irrelevant
                    // if the abovementioned Cache-Control parameters (no-cache,no-store,must-revalidate) are specified.


                    // Expires is per the HTTP 1.0 and 1.1 specs for clients and proxies.
                    // In HTTP 1.1, the Cache-Control takes precedence over Expires, so it's after all for HTTP 1.0 proxies only.
                    // If you don't care about HTTP 1.0 proxies, then you could omit Expires.
                    context.Context.Response.Headers["Expires"] = "-1, 0, Tue, 01 Jan 1980 1:00:00 GMT";

                    // The Pragma is per the HTTP 1.0 spec for prehistoric clients, such as Java WebClient
                    // If you don't care about IE6 nor HTTP 1.0 clients
                    // (HTTP 1.1 was introduced 1997), then you could omit Pragma.
                    context.Context.Response.Headers["pragma"] = "no-cache";


                    // On the other hand, if the server auto-includes a valid Date header,
                    // then you could theoretically omit Cache-Control too and rely on Expires only.

                    // Date: Wed, 24 Aug 2016 18:32:02 GMT
                    // Expires: 0

                    // But that may fail if e.g. the end-user manipulates the operating system date
                    // and the client software is relying on it.
                    // https://stackoverflow.com/questions/21120882/the-date-time-format-used-in-http-headers
                }     // End Sub OnPrepareResponse
            }
                );



            app.UseRouting();


            // https://stackoverflow.com/questions/60791843/changing-routedata-in-asp-net-core-3-1-in-middleware
            app.Use(
                async delegate(Microsoft.AspNetCore.Http.HttpContext context, System.Func <System.Threading.Tasks.Task> next)
            {
                string url           = context.Request.Headers["HOST"];
                string[] splittedUrl = url.Split('.');

                if (splittedUrl != null && (splittedUrl.Length > 0))
                {
                    context.GetRouteData().Values.Add("Host", splittedUrl[0]);
                    // context.GetRouteData().Values["controller"] = "test";
                }     // End if (splittedUrl != null && (splittedUrl.Length > 0))


                // if (splittedUrl != null && (splittedUrl.Length > 0 && splittedUrl[0] == "admin"))
                // {
                //     context.GetRouteData().Values.Add("area", "Admin");
                // }


                // Call the next delegate/middleware in the pipeline
                await next();
            }
                );


            app.UseAuthorization();

            /*
             * app.UseMvc(
             *  delegate(IRouteBuilder routes)
             *  {
             *      routes.DefaultHandler = new Microsoft.AspNetCore.Mvc.Routing.AreaRouter();
             *      // routes.MapRoute(name: "areaRoute", template: "{controller=Home}/{action=Index}");
             *  }
             * );
             */



            // https://stackoverflow.com/questions/278668/is-it-possible-to-make-an-asp-net-mvc-route-based-on-a-subdomain

            // https://stackoverflow.com/questions/57172884/mapping-subdomains-to-areas-in-asp-net-core-3
            app.UseEndpoints(
                delegate(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints)
            {
                endpoints.MapDynamicControllerRoute <SearchValueTransformer>("search/{**product}");
                // de.bar.int:5001/

                endpoints.MapControllerRoute(
                    name: "default",
                    // pattern: "{controller=Home}/{action=Index}/{id?}",
                    // pattern: "{controller=Blog}/{action=Index}/{id?}",
                    pattern: "{controller=Blog}/{action=ShowEntry}/{id?}"
                    );
            }
                );
        } // End Sub Configure
Exemple #3
0
        public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app)
        {
            app.UseEndpointRouting();

            app.UseEndpoint();
        }
Exemple #4
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app)
 {
     app.UseMvc();
     app.UseMiddleware <HttpMiddleware>(_middlewares, _serviceEntryContainer, _logger);
 }
Exemple #5
0
 public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJimuSwagger(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, string version = "v1")
 {
     app.UseSwaggerUI(c =>
     {
         c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"Jimu API {version}");
     });
     app.UseSwagger();
     return(app);
 }
Exemple #6
0
 /// <summary>
 /// Add Coddee <see cref="DynamicApi"/> middleware
 /// </summary>
 public static IApplicationBuilder UseCoddeeDynamicApi(this IApplicationBuilder appBuilder)
 {
     appBuilder.UseMiddleware <DynamicApi>();
     return(appBuilder);
 }
Exemple #7
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
 {
     app.UseAuthentication();
     app.UseRepositorySyncHub();
     app.UseCoddeeDynamicApi();
 }
 /// <summary>
 /// Added the middlware that creates and disposes a <see cref="IRenderEngine"/> for each request
 /// </summary>
 /// <param name="app">The application.</param>
 public static void UseJsEngine(this AppBuilder app)
 {
     app.UseMiddleware <RenderEngineMiddleware>();
 }
Exemple #9
0
 public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseErrorHandlingMiddleware(
     this Microsoft.AspNetCore.Builder.IApplicationBuilder app)
 {
     app.UseMiddleware <ErrorHandlingMiddleware>();
     return(app);
 } // End Function UseErrorHandlingMiddleware
Exemple #10
0
 private void ConfigureJWT(Microsoft.AspNetCore.Builder.IApplicationBuilder app)
 {
     app.UseAuthentication();
 }
Exemple #11
0
 public void UseMiddleware(Microsoft.AspNetCore.Builder.IApplicationBuilder app)
 {
     app.UseMiddleware <RaftMiddleware>(this);
 }
Exemple #12
0
        // This method gets called by the runtime.
        // Use this method to configure the HTTP request pipeline.
        public void Configure(
            Microsoft.AspNetCore.Builder.IApplicationBuilder app,
            Microsoft.AspNetCore.Hosting.IHostingEnvironment env)
        {
            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedFor
                                   | Microsoft.AspNetCore.HttpOverrides.ForwardedHeaders.XForwardedProto
            });



            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }


            app.UseDefaultFiles(
                new Microsoft.AspNetCore.Builder.DefaultFilesOptions()
            {
                DefaultFileNames = new System.Collections.Generic.List <string>()
                {
                    "index.htm", "index.html", "slick.htm"
                }
            }
                );


            app.UseStaticFiles(new StaticFileOptions()
            {
                ServeUnknownFileTypes = true,
                DefaultContentType    = "application/octet-stream",
                ContentTypeProvider   = new ExtensionContentTypeProvider(),

                OnPrepareResponse = delegate(Microsoft.AspNetCore.StaticFiles.StaticFileResponseContext context)
                {
                    // https://stackoverflow.com/questions/49547/how-do-we-control-web-page-caching-across-all-browsers

                    // The Cache-Control is per the HTTP 1.1 spec for clients and proxies
                    // If you don't care about IE6, then you could omit Cache-Control: no-cache.
                    // (some browsers observe no-store and some observe must-revalidate)
                    context.Context.Response.Headers["Cache-Control"] = "no-cache, no-store, must-revalidate, max-age=0";
                    // Other Cache-Control parameters such as max-age are irrelevant
                    // if the abovementioned Cache-Control parameters (no-cache,no-store,must-revalidate) are specified.


                    // Expires is per the HTTP 1.0 and 1.1 specs for clients and proxies.
                    // In HTTP 1.1, the Cache-Control takes precedence over Expires, so it's after all for HTTP 1.0 proxies only.
                    // If you don't care about HTTP 1.0 proxies, then you could omit Expires.
                    context.Context.Response.Headers["Expires"] = "-1, 0, Tue, 01 Jan 1980 1:00:00 GMT";

                    // The Pragma is per the HTTP 1.0 spec for prehistoric clients, such as Java WebClient
                    // If you don't care about IE6 nor HTTP 1.0 clients
                    // (HTTP 1.1 was introduced 1997), then you could omit Pragma.
                    context.Context.Response.Headers["pragma"] = "no-cache";


                    // On the other hand, if the server auto-includes a valid Date header,
                    // then you could theoretically omit Cache-Control too and rely on Expires only.

                    // Date: Wed, 24 Aug 2016 18:32:02 GMT
                    // Expires: 0

                    // But that may fail if e.g. the end-user manipulates the operating system date
                    // and the client software is relying on it.
                    // https://stackoverflow.com/questions/21120882/the-date-time-format-used-in-http-headers
                }
            });

            Microsoft.AspNetCore.Builder.WebSocketOptions webSocketOptions = new Microsoft.AspNetCore.Builder.WebSocketOptions()
            {
                KeepAliveInterval = System.TimeSpan.FromSeconds(120),
                ReceiveBufferSize = 4 * 1024
            };


            app.UseWebSockets(webSocketOptions);
            app.UseOpenFolderOrFileExtensions("/OpenFolder");
            app.UseRansackSearch("/ransack");
            app.UseRansackSearchAndReplace("/sar");
            app.UseTable("/table");
            app.UseFileContents("/textfile");

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        } // End Sub Configure
 UseExceptionHandlingMiddleware(this Microsoft.AspNetCore.Builder.IApplicationBuilder builder)
 {
     // UseMiddleware -> Extension Method -> using Microsoft.AspNetCore.Builder;
     return(builder.UseMiddleware
            <LoggingMicroservice.Api.Infrastructure.Middlewares.ExceptionHandlingMiddleware>());
 }