Reacting to new Hosting API

This commit is contained in:
John Luo 2015-12-18 16:35:11 -08:00
parent 9b9fd5ff00
commit 55d9e6ee4a
4 changed files with 16 additions and 37 deletions

View File

@ -1,31 +0,0 @@
using System;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.Configuration;
namespace MusicStore
{
/// <summary>
/// This demonstrates how the application can be launched in a console application.
/// "dnx run" command in the application folder will invoke this.
/// </summary>
public class Program
{
public static void Main(string[] args)
{
//Add command line configuration source to read command line parameters.
var builder = new ConfigurationBuilder();
builder.AddCommandLine(args);
var config = builder.Build();
using (new WebHostBuilder(config)
.UseServerFactory("Microsoft.AspNet.Server.WebListener")
.Build()
.Start())
{
Console.WriteLine("Started the server..");
Console.WriteLine("Press any key to stop the server");
Console.ReadLine();
}
}
}
}

View File

@ -1,4 +1,5 @@
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Configuration;
@ -219,5 +220,15 @@ namespace MusicStore
//Populates the MusicStore sample data
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
}
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
}
}

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -5,6 +5,7 @@
"description": "Music store application on ASP.NET 5",
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true,
"warningsAsErrors": true,
"define": [ "DEMO", "TESTING" ]
},
@ -12,7 +13,6 @@
"../../shared/**/*.cs"
],
"publishExclude": "*.cmd",
"webroot": "wwwroot",
"dependencies": {
"EntityFramework.InMemory": "7.0.0-*",
"EntityFramework.MicrosoftSqlServer": "7.0.0-*",
@ -39,11 +39,7 @@
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0-*"
},
"commands": {
"gen": "Microsoft.Extensions.CodeGeneration",
"run": "run server.urls=http://localhost:5003",
"web": "Microsoft.AspNet.Server.Kestrel",
"kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5004",
"weblistener": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002"
"web": "MusicStore"
},
"frameworks": {
"dnx451": { },