当前位置: 首页>>代码示例>>C#>>正文


C# IApplicationBuilder.UseDefaultFiles方法代码示例

本文整理汇总了C#中IApplicationBuilder.UseDefaultFiles方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseDefaultFiles方法的具体用法?C# IApplicationBuilder.UseDefaultFiles怎么用?C# IApplicationBuilder.UseDefaultFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IApplicationBuilder的用法示例。


在下文中一共展示了IApplicationBuilder.UseDefaultFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

        // 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)
        {
            // Configuration
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            builder.AddEnvironmentVariables();
            builder.Build();

            // Logging
            loggerFactory.AddDebug(minLevel: LogLevel.Verbose);
            
            // Using different environments
            if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase)) { }

            // Middlewares
            app.UseDeveloperExceptionPage();
            app.UseRuntimeInfoPage(); // default path is /runtimeinfo            
            app.UseDefaultFiles();
            app.UseStaticFiles();

            // Web sockets
            app.Map("/Managed", (appBuilder) => WebSocketsHelper.Configure(appBuilder, loggerFactory));

            // IIS
            app.UseIISPlatformHandler();
        }
开发者ID:streamcode9,项目名称:chat,代码行数:29,代码来源:Startup.cs

示例2: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            // Configure the HTTP request pipeline.

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseErrorPage();
                app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // sends the request to the following path or controller action.
                app.UseErrorHandler("/Home/Error");
            }

            // Serve the default file, if present.
            app.UseDefaultFiles();
            // Add static files to the request pipeline.
            app.UseStaticFiles();

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }
开发者ID:jvf00,项目名称:WebApplication1,代码行数:28,代码来源:Startup.cs

示例3: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            if(env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            
            loggerFactory
                .AddConsole(Configuration.GetSection("Logging"))
                .AddDebug();
            
            // Use the Default files ['index.html', 'index.htm', 'default.html', 'default.htm']
            app.UseDefaultFiles()
                .UseStaticFiles()
                .UseIISPlatformHandler()
                .UseMvc();

            // Setup a generic Quotes API EndPoint
            app.Map("/api/quotes", (config) =>
            {
                app.Run(async context =>
                {
                    var quotes = "{ \"quotes\":" +
                                 " [ { \"quote\": \"Duct tape is like the force. It has a light side, a dark side, and it holds the universe together.\", \"author\":\"Oprah Winfrey\"} ]" +
                                 "}";
                    context.Response.ContentLength = quotes.Length;
                    context.Response.ContentType = "application/json";                    
                    await context.Response.WriteAsync(quotes);
                });
            });
        }
开发者ID:jtucker,项目名称:aspnet5-angular2-starter,代码行数:32,代码来源:Startup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

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

            app.UseDefaultFiles();
            var contentTypeProvider = new FileExtensionContentTypeProvider();
            contentTypeProvider.Mappings[".nzd"] = "application/octet-stream";
            app.UseStaticFiles(new StaticFileOptions
            {
                ContentTypeProvider = contentTypeProvider
            });

            // At some stage we may want an MVC view for the home page, but at the moment
            // we're just serving static files, so we don't need much.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });
        }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:32,代码来源:Startup.cs

示例5: Configure

        // 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors("CorsPolicy");

            app.UseDefaultFiles();
            app.UseStaticFiles();

            var tokenValidationParameters = CreateTokenValidationParameters();
            app.UseJwtBearerAuthentication(new JwtBearerOptions
            {
                AutomaticAuthenticate = true,
                AutomaticChallenge = true,
                TokenValidationParameters = tokenValidationParameters
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "Default",
                    template: "api/{controller}/{action}/{id?}"
                );
            });
        }
开发者ID:AlinCiocan,项目名称:FoodPlanApp,代码行数:32,代码来源:Startup.cs

示例6: Configure

 // Configure is called after ConfigureServices is called.
 public void Configure(IApplicationBuilder app)
 {
     // Configure the HTTP request pipeline.
     app.UseDefaultFiles();
     app.UseStaticFiles();
     app.UseMvc();
 }       
开发者ID:freemsly,项目名称:mvc6-angularjs-mongodb,代码行数:8,代码来源:Startup.cs

示例7: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseMvc();
        }
开发者ID:Lejdholt,项目名称:vnext-example,代码行数:7,代码来源:Startup.cs

示例8: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.UseDefaultFiles();
     app.UseStaticFiles();
     var application = new CardApplication(new SocketServer());
     application.Start();
 }
开发者ID:Sharpiro,项目名称:Websockets.Template,代码行数:7,代码来源:Startup.cs

示例9: Configure

        // 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)
        {
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Use(async (context, next) =>
            {
                await next();
                if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value))
                {
                    context.Request.Path = "/index.html"; // Put your Angular root page here 
                    await next();
                }
            });

            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseMvcWithDefaultRoute();

            
        }
开发者ID:yeseniamolinab,项目名称:yesymolina.net,代码行数:27,代码来源:Startup.cs

示例10: Configure

 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app) {
     app
         .UseDefaultFiles()
         .UseStaticFiles()
         .UseDeveloperExceptionPage()
         .UseMvc();
 }
开发者ID:aleksgorbach,项目名称:ProtectionTools,代码行数:8,代码来源:Startup.cs

示例11: Configure

 public void Configure(IApplicationBuilder app)
 {   
     Log("WWWService Configure()");           
     app.UseDefaultFiles();
     app.UseStaticFiles();
     app.UseMvc();            
 }            
开发者ID:strabu,项目名称:SeedAspNetVNextInWindowsService,代码行数:7,代码来源:Program.cs

示例12: Configure

        // 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

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

            app.UseWebSockets();
            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.Map("/Preview/Socket", PreviewSocketHandler.Map);
            app.Map("/Index/Socket", DashboardSocketHandler.Map);
            app.Map("/SACNTransmitters/Socket", SACNTransmitterLive.Map);
            app.Map("/OSCListeners/Socket", OSCListenerLive.Map);
            app.Map("/RawDMX/Socket", RawDMXSocketHandler.Map);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:iKadmium,项目名称:kadmium-osc-dmx-dotnet,代码行数:32,代码来源:Startup.cs

示例13: Configure

        public void Configure(IApplicationBuilder app)
        {
            // Initialise ReactJS.NET. Must be before static files.
            app.UseReact(config =>
            {
                // If you want to use server-side rendering of React components,
                // add all the necessary JavaScript files here. This includes
                // your components as well as all of their dependencies.
                // See http://reactjs.net/ for more information. Example:
                //config
                //    .AddScript("~/Scripts/First.jsx")
                //    .AddScript("~/Scripts/Second.jsx");

                // If you use an external build too (for example, Babel, Webpack,
                // Browserify or Gulp), you can improve performance by disabling
                // ReactJS.NET's version of Babel and loading the pre-transpiled
                // scripts. Example:
                //config
                //    .SetLoadBabel(false)
                //    .AddScriptWithoutTransform("~/Scripts/bundle.server.js");
            });

            // Add the platform handler to the request pipeline.
            app.UseIISPlatformHandler();

            //设定静态文件的默认文档
            app.UseDefaultFiles(new DefaultFilesOptions()
            {
                DefaultFileNames = new string[] { "index.html", "index.htm" }
            });
            app.UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseMvc();
        }
开发者ID:scfido,项目名称:ReactDemo,代码行数:35,代码来源:Startup.cs

示例14: Configure

        // 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

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

            app.UseIISPlatformHandler();
            //app.UseMvc(ConfigureRoutes);

            app.UseDefaultFiles();
            app.UseStaticFiles();
            //app.UseFileServer(enableDirectoryBrowsing: true);
            //app.UseDirectoryBrowser();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    //template: "{controller=Workspace}/{action=WorkspaceHello}/{id?}");
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:tsaltd,项目名称:AvantTekWebsiteAlpha,代码行数:32,代码来源:Startup.cs

示例15: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();

            // Configure the HTTP request pipeline.

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                //app.UseErrorPage(ErrorPageOptions.ShowAll);
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // send the request to the following path or controller action.
                app.UseErrorHandler("/Home/Error");
            }

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            app.UseDefaultFiles(new Microsoft.AspNet.StaticFiles.DefaultFilesOptions() { DefaultFileNames = new[] { "index.html" } });
            // Add MVC to the request pipeline.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                // Uncomment the following line to add a route for porting Web API 2 controllers.
                // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
            });
        }
开发者ID:mobiledesignslns,项目名称:VisualStudio2015Gulp,代码行数:36,代码来源:Startup.cs


注:本文中的IApplicationBuilder.UseDefaultFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。