1
0
mirror of https://github.com/Microsoft/sql-server-samples.git synced 2025-12-08 14:58:54 +00:00
Files
sql-server-samples/samples/features/json/reactjs/dotnet-comments-app/Startup.cs
Jovan Popovic c1b729cd6d ReactJS app moved to different folder
ReactJS app is moved to reactjs/dotnet-comment-app. Removed
project.lock.json file from source control.
2016-10-29 09:14:27 -07:00

49 lines
1.8 KiB
C#

using Belgrade.SqlClient;
using Belgrade.SqlClient.SqlDb;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System.Data.SqlClient;
namespace ReactCommentsApp
{
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
string ConnString = Configuration["ConnectionStrings:CommentsDb"];
services.AddTransient<IQueryPipe>( _=> new QueryPipe(new SqlConnection(ConnString)));
services.AddTransient<ICommand>( _=> new Command(new SqlConnection(ConnString)));
// Add framework services.
services.AddMvc();
}
// 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.UseMvc();
app.UseStaticFiles();
}
}
}