Reacting to hew Hosting API
This commit is contained in:
parent
8d261f8116
commit
2b2c42069c
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.StaticFiles;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
|
@ -22,5 +23,15 @@ namespace StaticFilesSample
|
|||
EnableDirectoryBrowsing = true,
|
||||
});
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var application = new WebApplicationBuilder()
|
||||
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
|
||||
application.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"server": "Microsoft.AspNet.Server.Kestrel"
|
||||
}
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"commands": {
|
||||
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.Urls http://localhost:12345/"
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {},
|
||||
"dnxcore50": {}
|
||||
},
|
||||
"webroot": "wwwroot"
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"commands": {
|
||||
"web": "StaticFileSample"
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
"dnxcore50": { }
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
|
@ -4,10 +4,10 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.AspNet.Testing.xunit;
|
||||
|
|
@ -20,7 +20,9 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
[Fact]
|
||||
public async Task ReturnsNotFoundWithoutWwwroot()
|
||||
{
|
||||
var server = TestServer.Create(app => app.UseStaticFiles());
|
||||
var builder = new WebApplicationBuilder()
|
||||
.Configure(app => app.UseStaticFiles());
|
||||
var server = new TestServer(builder);
|
||||
|
||||
var response = await server.CreateClient().GetAsync("/ranges.txt");
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.TestHost;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -19,7 +20,11 @@ namespace Microsoft.AspNet.StaticFiles
|
|||
{
|
||||
new KeyValuePair<string, string>("webroot", ".")
|
||||
});
|
||||
return TestServer.Create(configurationBuilder.Build(), configureApp, configureServices: configureServices);
|
||||
var builder = new WebApplicationBuilder()
|
||||
.UseConfiguration(configurationBuilder.Build())
|
||||
.Configure(configureApp)
|
||||
.ConfigureServices(configureServices);
|
||||
return new TestServer(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue