Reacting to new Hosting API
This commit is contained in:
parent
b1a671f3fc
commit
efcc7ae956
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
|
using Microsoft.AspNet.Hosting;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
@ -28,5 +29,15 @@ namespace IISSample
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
@ -3,12 +3,13 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
|
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
|
||||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||||
},
|
},
|
||||||
|
"compilationOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
"commands": {
|
"commands": {
|
||||||
"web": "Microsoft.AspNet.Server.Kestrel",
|
"web": "IISSample"
|
||||||
"weblistener": "Microsoft.AspNet.Server.WebListener"
|
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnx451": { },
|
"dnx451": { },
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
|
using Microsoft.AspNet.Hosting;
|
||||||
using Microsoft.AspNet.Http.Features.Authentication;
|
using Microsoft.AspNet.Http.Features.Authentication;
|
||||||
using Microsoft.AspNet.TestHost;
|
using Microsoft.AspNet.TestHost;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
@ -17,18 +18,20 @@ namespace Microsoft.AspNet.IISPlatformHandler
|
||||||
{
|
{
|
||||||
var assertsExecuted = false;
|
var assertsExecuted = false;
|
||||||
|
|
||||||
var server = TestServer.Create(app =>
|
var builder = new WebApplicationBuilder()
|
||||||
{
|
.Configure(app =>
|
||||||
app.UseIISPlatformHandler();
|
|
||||||
app.Run(context =>
|
|
||||||
{
|
{
|
||||||
var auth = (IHttpAuthenticationFeature)context.Features[typeof(IHttpAuthenticationFeature)];
|
app.UseIISPlatformHandler();
|
||||||
Assert.NotNull(auth);
|
app.Run(context =>
|
||||||
Assert.Equal("Microsoft.AspNet.IISPlatformHandler.AuthenticationHandler", auth.Handler.GetType().FullName);
|
{
|
||||||
assertsExecuted = true;
|
var auth = (IHttpAuthenticationFeature)context.Features[typeof(IHttpAuthenticationFeature)];
|
||||||
return Task.FromResult(0);
|
Assert.NotNull(auth);
|
||||||
|
Assert.Equal("Microsoft.AspNet.IISPlatformHandler.AuthenticationHandler", auth.Handler.GetType().FullName);
|
||||||
|
assertsExecuted = true;
|
||||||
|
return Task.FromResult(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
var server = new TestServer(builder);
|
||||||
|
|
||||||
var req = new HttpRequestMessage(HttpMethod.Get, "");
|
var req = new HttpRequestMessage(HttpMethod.Get, "");
|
||||||
await server.CreateClient().SendAsync(req);
|
await server.CreateClient().SendAsync(req);
|
||||||
|
|
@ -41,17 +44,19 @@ namespace Microsoft.AspNet.IISPlatformHandler
|
||||||
{
|
{
|
||||||
var assertsExecuted = false;
|
var assertsExecuted = false;
|
||||||
|
|
||||||
var server = TestServer.Create(app =>
|
var builder = new WebApplicationBuilder()
|
||||||
{
|
.Configure(app =>
|
||||||
app.UseIISPlatformHandler(options => options.FlowWindowsAuthentication = false);
|
|
||||||
app.Run(context =>
|
|
||||||
{
|
{
|
||||||
var auth = (IHttpAuthenticationFeature)context.Features[typeof(IHttpAuthenticationFeature)];
|
app.UseIISPlatformHandler(options => options.FlowWindowsAuthentication = false);
|
||||||
Assert.Null(auth);
|
app.Run(context =>
|
||||||
assertsExecuted = true;
|
{
|
||||||
return Task.FromResult(0);
|
var auth = (IHttpAuthenticationFeature)context.Features[typeof(IHttpAuthenticationFeature)];
|
||||||
|
Assert.Null(auth);
|
||||||
|
assertsExecuted = true;
|
||||||
|
return Task.FromResult(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
var server = new TestServer(builder);
|
||||||
|
|
||||||
var req = new HttpRequestMessage(HttpMethod.Get, "");
|
var req = new HttpRequestMessage(HttpMethod.Get, "");
|
||||||
await server.CreateClient().SendAsync(req);
|
await server.CreateClient().SendAsync(req);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue