protected override void OnStart(string[] args) { try { var temp = new ConfigurationBuilder() .AddJsonFile("config.json") .AddJsonFile("hosting.json", true) .Build(); var configProvider = new MemoryConfigurationProvider(); configProvider.Add("server.urls", temp["WebServerAddress"]); configProvider.Add("webroot", temp.Get <string>("webroot", "wwwroot")); var config = new ConfigurationBuilder() .Add(configProvider) .Build(); var builder = new WebHostBuilder(config); builder.UseServer("Microsoft.AspNet.Server.Kestrel"); builder.UseStartup <Startup>(); var hostingEngine = builder.Build(); _application = hostingEngine.Start(); } catch (Exception ex) { Debug.WriteLine("error in OnStart: " + ex); throw; } }
protected override void OnStart(string[] args) { try { var temp = new ConfigurationBuilder() .AddJsonFile("config.json") .AddJsonFile("hosting.json", true) .Build(); var configProvider = new MemoryConfigurationProvider(); configProvider.Add("server.urls", temp["WebServerAddress"]); configProvider.Add("webroot", temp.Get<string>("webroot", "wwwroot")); var config = new ConfigurationBuilder() .Add(configProvider) .Build(); var builder = new WebHostBuilder(config); builder.UseServer("Microsoft.AspNet.Server.Kestrel"); builder.UseStartup<Startup>(); var hostingEngine = builder.Build(); _application = hostingEngine.Start(); } catch (Exception ex) { Debug.WriteLine("error in OnStart: " + ex); throw; } }
public IConfigurationProvider Build(IConfigurationBuilder builder) { var provider = new MemoryConfigurationProvider(this); provider.Add("MiniServer:HostName", "testminiserver.loxone.com"); provider.Add("MiniServer:Port", "7777"); provider.Add("MiniServer:UserName", "web"); provider.Add("MiniServer:Password", "web"); return(provider); }
protected override void OnStart(string[] args) { try { var configProvider = new MemoryConfigurationProvider(); configProvider.Add("server.urls", "http://localhost:5000"); var config = new ConfigurationBuilder() .Add(configProvider) .Build(); var builder = new WebHostBuilder(config); builder.UseServer("Microsoft.AspNet.Server.Kestrel"); builder.UseServices(services => services.AddMvc()); builder.UseStartup(appBuilder => { appBuilder.UseDefaultFiles(); appBuilder.UseStaticFiles(); appBuilder.UseMvc(); }); var hostingEngine = builder.Build(); _application = hostingEngine.Start(); } catch (Exception ex) { Debug.WriteLine("error in OnStart: " + ex); throw; } }
protected override void OnStart(string[] args) { var configProvider = new MemoryConfigurationProvider(); configProvider.Add("server.urls", "http://localhost:5000"); configProvider.Add("webroot", "root2"); var config = new ConfigurationBuilder() .Add(configProvider) .AddJsonFile("hosting.json", optional: true) .Build(); _application = new WebHostBuilder(config) .UseServer("Microsoft.AspNet.Server.Kestrel") .UseStartup <Program>() .Build() .Start(); }
protected override void OnStart(string[] args) { try { var configProvider = new MemoryConfigurationProvider(); configProvider.Add("server.urls", "http://localhost:5000"); var config = new ConfigurationBuilder() .Add(configProvider) .Build(); var builder = new WebHostBuilder(config); builder.UseServer("Microsoft.AspNet.Server.Kestrel"); builder.UseServices(services => { services.AddMvc(opts => { // none }); }); builder.UseStartup(appBuilder => { appBuilder.Use(async (ctx, next) => { try { await next(); } catch (Exception ex) { Console.WriteLine(ex); } }); appBuilder.UseDefaultFiles(); appBuilder.UseStaticFiles(); appBuilder.UseMvc(); //if (env.IsDevelopment()) { appBuilder.UseBrowserLink(); appBuilder.UseDeveloperExceptionPage(); appBuilder.UseDatabaseErrorPage(); } }); var hostingEngine = builder.Build(); _application = hostingEngine.Start(); } catch (Exception ex) { Debug.WriteLine("error in OnStart: " + ex); throw; } }
protected override void OnStart(string[] args) { try { var configProvider = new MemoryConfigurationProvider(); configProvider.Add("server.urls", "http://localhost:5000"); var config = new ConfigurationBuilder() .Add(configProvider) .Build(); var builder = new WebHostBuilder(config); builder.UseServer("Microsoft.AspNet.Server.Kestrel"); builder.UseServices(services => { services.AddMvc(opts => { // none }); }); builder.UseStartup(appBuilder => { appBuilder.Use(async(ctx, next) => { try { await next(); } catch (Exception ex) { Console.WriteLine(ex); } }); appBuilder.UseDefaultFiles(); appBuilder.UseStaticFiles(); appBuilder.UseMvc(); //if (env.IsDevelopment()) { appBuilder.UseBrowserLink(); appBuilder.UseDeveloperExceptionPage(); appBuilder.UseDatabaseErrorPage(); } }); var hostingEngine = builder.Build(); _application = hostingEngine.Start(); } catch (Exception ex) { Debug.WriteLine("error in OnStart: " + ex); throw; } }
private static IConfiguration SetUpDefaultAssembly(string assemblyName) { var source = new MemoryConfigurationProvider(); source.Add("defaultAssembly", assemblyName); var config = new ConfigurationBuilder(); config.Add(source); return(config.Build()); }
public static void Init(string environment = null, string basePath = null, IDictionary <string, string> inMemoryConfigs = null) { var builder = new ConfigurationBuilder(); var memoryProvider = new MemoryConfigurationProvider(new MemoryConfigurationSource()); if (inMemoryConfigs != null) { foreach (var config in inMemoryConfigs) { memoryProvider.Add(config.Key, config.Value); } } Environment = !string.IsNullOrWhiteSpace(environment) ? environment : "dev"; BasePath = !string.IsNullOrWhiteSpace(basePath) ? basePath : Directory.GetCurrentDirectory(); builder.SetBasePath(BasePath); builder.AddInMemoryCollection(memoryProvider); builder.AddJsonFile($"appsettings.{Environment}.json", optional: true, reloadOnChange: true); builder.AddJsonFile($"appsettings.json", optional: true, reloadOnChange: true); Configuration = builder.Build(); }
private static IConfiguration SetUpDefaultAssembly(string assemblyName) { var source = new MemoryConfigurationProvider(); source.Add("defaultAssembly", assemblyName); var config = new ConfigurationBuilder(); config.Add(source); return config.Build(); }