aspnetcore/samples/IISSample/Startup.cs

33 lines
1.1 KiB
C#

using System;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Framework.Logging;
namespace IISSample
{
public class Startup
{
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
{
loggerfactory.AddConsole(LogLevel.Verbose);
var logger = loggerfactory.CreateLogger("Requests");
app.UseIISPlatformHandler();
app.Run(async (context) =>
{
logger.LogVerbose("Received request: " + context.Request.Method + " " + context.Request.Path);
context.Response.ContentType = "text/plain";
await context.Response.WriteAsync("Hello World - " + DateTimeOffset.Now + Environment.NewLine);
await context.Response.WriteAsync("User - " + context.User.Identity.Name + Environment.NewLine);
foreach (var header in context.Request.Headers)
{
await context.Response.WriteAsync(header.Key + ": " + header.Value + Environment.NewLine);
}
});
}
}
}