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


C# IHostingEnvironment.IsDevelopment方法代码示例

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


在下文中一共展示了IHostingEnvironment.IsDevelopment方法的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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
	    _logger = loggerFactory.CreateLogger("Test");
	    _logger.LogInformation("Starting Jacks logging");
            
	    if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseIISPlatformHandler();

            app.UseStaticFiles();
	    app.UseSignalR2();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
	    
	    _dm = new DownloadManager(_logger, GlobalHost.ConnectionManager.GetHubContext<Scraper.Hubs.ChatHub>());
	    
	    Console.CancelKeyPress += (s,e) => { _logger.LogInformation("CTRL+C detected - shutting down"); _dm.Stop(); };
        }
开发者ID:sheepshaker,项目名称:Scraper,代码行数:32,代码来源:Startup.cs

示例2: 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.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseIdentity();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            if (env.IsDevelopment())
            {
                //SeedOfficers(app.ApplicationServices);
                //HotFix_RevisedTime (app.ApplicationServices);
            }
        }
开发者ID:ZhangYuef,项目名称:Survey_Platform_ccer,代码行数:34,代码来源:Startup.cs

示例3: 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.UseIISPlatformHandler();

            if (env.IsDevelopment()) {
                app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
                    HotModuleReplacement = true
                });
            }

            app.UseStaticFiles();

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

示例4: 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();

            app.UseMiddleware<Middleware.FilterLinkProbes>();

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

            
            app.UseIISPlatformHandler();

            if (!env.IsDevelopment())
            {
                // This has to come after UseIISPlatformHandler(), otherwise
                // the request context will always think it's HTTP
                app.UseMiddleware<Middleware.EnforceHttps>();
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{action=Set}",
                    defaults: new {controller = "Home"});
            });
        }
开发者ID:vsliouniaev,项目名称:pass-cache-2,代码行数:34,代码来源:Startup.cs

示例5: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment environment, ILoggerFactory factory) {
            factory.AddConsole();
            factory.AddDebug();

            app.UseIISPlatformHandler();

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

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

            // Add a new middleware validating access tokens.
            app.UseJwtBearerAuthentication(options => {
                // Automatic authentication must be enabled
                // for SignalR to receive the access token.
                options.AutomaticAuthenticate = true;

                // Automatically disable the HTTPS requirement for development scenarios.
                options.RequireHttpsMetadata = !environment.IsDevelopment();

                // Note: the audience must correspond to the address of the SignalR server.
                options.Audience = "http://localhost:5000/";

                // Note: the authority must match the address of the identity server.
                options.Authority = "http://localhost:5000/";

                options.Events = new JwtBearerEvents {
                    // Note: for SignalR connections, the default Authorization header does not work,
                    // because the WebSockets JS API doesn't allow setting custom parameters.
                    // To work around this limitation, the access token is retrieved from the query string.
                    OnReceivingToken = context => {
                        // Note: when the token is missing from the query string,
                        // context.Token is null and the JWT bearer middleware will
                        // automatically try to retrieve it from the Authorization header.
                        context.Token = context.Request.Query["access_token"];

                        return Task.FromResult(0);
                    }
                };
            });

            app.UseWebSockets();

            app.UseSignalR<SimpleConnection>("/signalr");

            // Add a new middleware issuing access tokens.
            app.UseOpenIdConnectServer(options => {
                options.Provider = new AuthenticationProvider();
            });
        }
开发者ID:DovydasNavickas,项目名称:AspNet.Security.OpenIdConnect.Samples,代码行数:52,代码来源:Startup.cs

示例6: Startup

        public Startup(IHostingEnvironment env)
        {
            _isDevEnvironment = env.IsDevelopment();

            var builder = new ConfigurationBuilder()
                .AddJsonFile("Haufwerk.json")
                .AddEnvironmentVariables("Haufwerk:");
            if (env.IsDevelopment())
            {
                // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
                builder.AddApplicationInsightsSettings(true);
            }
            Configuration = builder.Build();
        }
开发者ID:saxx,项目名称:Haufwerk,代码行数:14,代码来源:Startup.cs

示例7: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            
            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // send the request to the following path or controller action.
                app.UseExceptionHandler("/Home/Error");
            }

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

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

            // Add MVC to the request pipeline.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
                    
                routes.MapRoute("DefaultApi", "api/{controller}/{id?}");
            });
        }
开发者ID:zplanet,项目名称:expense-tracker-net,代码行数:34,代码来源:Startup.cs

示例8: Startup

        public Startup(
            IHostingEnvironment env,
            IApplicationEnvironment appEnv)
        {
            _env = env;

            // Setup configuration sources.
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                // standard config file
                .AddJsonFile("config.json")
                // environment specific config.<environment>.json file
                .AddJsonFile($"config.{env.EnvironmentName}.json", true /* override if exists */)
                // standard Windows environment variables
                .AddEnvironmentVariables();

            if (env.IsDevelopment())
            {
                // this one adds not using directive to keep it secret, only a dnx reference
                // the focus is not on Secrets but on User, so these are User specific settings
                // we can also make it available only for developers
                builder.AddUserSecrets();
            }

            Configuration = builder.Build();
        }
开发者ID:madrus,项目名称:mvaWebApp02,代码行数:26,代码来源:Startup.cs

示例9: 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

示例10: Configure

        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.UseStaticFiles();

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme = Constants.MiddlewareScheme,
                LoginPath = new PathString("/Account/Login/"),
                AccessDeniedPath = new PathString("/Account/Forbidden/"),
                AutomaticAuthenticate = true,
                AutomaticChallenge = true
            });

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

示例11: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnvironment)
        {
            _appEnvironment = appEnvironment;
            _hostingEnvironment = env;

            var RollingPath = Path.Combine(appEnvironment.ApplicationBasePath, "logs/myapp-{Date}.txt");
            Log.Logger = new LoggerConfiguration()
                .WriteTo.RollingFile(RollingPath)
                .CreateLogger();
            Log.Information("Ah, there you are!");

            // Set up configuration sources.
            var builder = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json")
                .AddJsonFile("appsettings-filters.json")
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            if (env.IsDevelopment())
            {
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets();
            }

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();

            // Initialize the global configuration static
            GlobalConfigurationRoot.Configuration = Configuration;
        }
开发者ID:ghstahl,项目名称:vNext.Jan2016Web,代码行数:29,代码来源:Startup.cs

示例12: ConfigureCookies

        /// <summary>
        /// Configure default cookie settings for the application which are more secure by default.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="environment">The environment the application is running under. This can be Development, 
        /// Staging or Production by default.</param>
        private static void ConfigureCookies(
            IApplicationBuilder application,
            IHostingEnvironment environment)
        {
            // In the Development environment, different ports are being used for HTTP and HTTPS. The 
            // RequireHttpsAttribute expects to use the default ports 80 for HTTP and port 443 for HTTPS and simply
            // adds an 's' onto 'http'. Therefore, we don't require secure cookies in the development environment.
            SecurePolicy securePolicy;
            if (environment.IsDevelopment())
            {
                // Ensure that the cookie can only be transported over the same scheme as the request.
                securePolicy = SecurePolicy.SameAsRequest;
            }
            else
            {
                // Ensure that the cookie can only be transported over HTTPS.
                securePolicy = SecurePolicy.Always;
            }

            application.UseCookiePolicy(
                new CookiePolicyOptions()
                {
                    // Ensure that external script cannot access the cookie.
                    HttpOnly = HttpOnlyPolicy.Always,
                    Secure = securePolicy
                });
        }
开发者ID:Pro-Coded,项目名称:Pro.MVCMagic,代码行数:33,代码来源:Startup.Cookies.cs

示例13: 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)
        {
            SuperDataBase.Configure(env, app.ApplicationServices.GetService<IOptions<AppConfig>>());

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

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

            app.UseIISPlatformHandler();

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

        }
开发者ID:marcodiniz,项目名称:TinBot,代码行数:30,代码来源:Startup.cs

示例14: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            // Configure the HTTP request pipeline.

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
            }

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

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

            // Add MVC to the request pipeline.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:AmerjitSingh,项目名称:Wsoft.IOT.Web,代码行数:28,代码来源:Startup.cs

示例15: Configure

        public void Configure(IApplicationBuilder app,
        IHostingEnvironment env,
        ILoggerFactory loggerFactory)
        {
            Log.Logger =
              new LoggerConfiguration()
                .MinimumLevel.Error()
                .WriteTo.TextWriter(System.Console.Out)
                .WriteTo.RollingFile(@"C:\temp\TSWebLog-{Date}.txt")
                .CreateLogger();

            loggerFactory.AddSerilog();

            app.UseStaticFiles();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }
开发者ID:hoetz,项目名称:aspnetCoreTypescriptKOSample,代码行数:26,代码来源:Startup.cs


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