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


C# IHostingEnvironment类代码示例

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


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

示例1: Configure

        // Configure is called after ConfigureServices is called.
        public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, MyHealthDataInitializer dataInitializer)
        {
            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();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage(options => options.EnableAll());
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // sends 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.ConfigureRoutes();

            await dataInitializer.InitializeDatabaseAsync(app.ApplicationServices, Configuration);
        }
开发者ID:geekpivot,项目名称:HealthClinic.biz,代码行数:34,代码来源:Startup.cs

示例2: Startup

 public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
 {
     var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
         .AddJsonFile("config.json")
         .AddEnvironmentVariables();
     Configuration = builder.Build();
 }
开发者ID:heberop,项目名称:tfspanel,代码行数:7,代码来源: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.UseStaticFiles();

            app.UseWebMarkupMin();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:Taritsyn,项目名称:WebMarkupMin,代码行数:26,代码来源: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)
        {
            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

示例5: Configure

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

            // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
            try
            {
                using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
                    .CreateScope())
                {
                    using (var db = serviceScope.ServiceProvider.GetService<ApplicationDbContext>())
                    {
                        db.Database.EnsureCreated();
                        db.Database.Migrate();
                    }
                }
            }
            catch (Exception exception)
            {
            }

            app.UseCors("AllowAllOrigins");         // TODO: allow collection of allowed origins per client
            app.UseIISPlatformHandler();
            app.UseStaticFiles();
            app.UseMvc();
        }
开发者ID:JGaudion,项目名称:openidconnect,代码行数:27,代码来源:Startup.cs

示例6: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            var configPath = Path.Combine(appEnv.ApplicationBasePath, "..", "..");

            Configuration = new Configuration(configPath).AddJsonFile("config.json").
                AddEnvironmentVariables("SmsPrize_");
        }
开发者ID:squideyes,项目名称:SmsPrize,代码行数:7,代码来源:Startup.cs

示例7: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
        {
            // Configure the HTTP request pipeline.

            // Add the console logger.
            loggerfactory.AddConsole(minLevel: LogLevel.Verbose);

            // Add the following to the request pipeline only in development environment.
            if (env.IsEnvironment("Development"))
            {
                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();

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

示例8: Startup

 public Startup(IHostingEnvironment env)
 {
     // Set up configuration sources.
     Configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json")
                                               .AddEnvironmentVariables()
                                               .Build();
 }
开发者ID:lawrencegripper,项目名称:Hosting,代码行数:7,代码来源:Startup.cs

示例9: Startup

        public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
        {
            //Setting up configuration builder
            var builder = new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddEnvironmentVariables();

            if (!env.IsProduction())
            {
                builder.AddUserSecrets();
            }
            else
            {

            }

            Configuration = builder.Build();

            //Setting up configuration
            if (!env.IsProduction())
            {
                var confConnectString = Configuration.GetSection("Data:DefaultConnection:ConnectionString");
                confConnectString.Value = @"Server=(localdb)\mssqllocaldb;Database=GetHabitsAspNet5;Trusted_Connection=True;";

                var identityConnection = Configuration.GetSection("Data:IdentityConnection:ConnectionString");
                identityConnection.Value = @"Server=(localdb)\mssqllocaldb;Database=GetHabitsIdentity;Trusted_Connection=True;";
            }
            else
            {

            }
        }
开发者ID:boyarincev,项目名称:GetHabitsAspNet5,代码行数:32,代码来源:Startup.cs

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

示例11: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            app.UseDeveloperExceptionPage();
            app.UseStaticFiles();

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme = "Cookies",
                AutomaticAuthenticate = true
            });

            app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
            {
                AuthenticationScheme = "oidc",
                SignInScheme = "Cookies",

                Authority = "https://demo.identityserver.io",
                PostLogoutRedirectUri = "http://localhost:3308/",
                ClientId = "hybrid",
                ClientSecret = "secret",
                ResponseType = "code id_token",
                GetClaimsFromUserInfoEndpoint = true,
                SaveTokens = true
            });

            app.UseMvcWithDefaultRoute();
        }
开发者ID:ReinhardHsu,项目名称:AspNetCoreSecuritySamples,代码行数:32,代码来源:Startup.cs

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

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

示例14: Startup

		public Startup(IHostingEnvironment hostingEnvironment, IApplicationEnvironment applicationEnvironment)
		{
			Configuration = new ConfigurationBuilder()
				.SetBasePath(applicationEnvironment.ApplicationBasePath)
				.AddJsonFile("config.json")
				.Build();
		}
开发者ID:qbikez,项目名称:Odachi,代码行数:7,代码来源:Startup.cs

示例15: Configure

 // Configure is called after ConfigureServices is called.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     // Add MVC to the request pipeline.
     app.UseMvc();
     // Add the following route for porting Web API 2 controllers.
     // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
 }
开发者ID:jamisliao,项目名称:aws-sdk-net-samples,代码行数:8,代码来源:Startup.cs


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