From bda750bde73c5f34f368c457a94c85c1b6d724e3 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Sat, 25 Jun 2016 11:08:06 -0700 Subject: [PATCH] Migrate middlware docs (#1513) --- aspnet/fundamentals/middleware.rst | 2 +- .../middleware/sample/global.json | 5 +-- .../sample/src/MiddlewareSample/Program.cs | 20 ++++++++++ .../RequestLoggerExtensions.cs | 2 +- .../RequestLoggerMiddleware.cs | 5 +-- .../sample/src/MiddlewareSample/Startup.cs | 10 ++--- .../sample/src/MiddlewareSample/hosting.ini | 2 - .../sample/src/MiddlewareSample/project.json | 38 +++++++------------ 8 files changed, 43 insertions(+), 41 deletions(-) create mode 100644 aspnet/fundamentals/middleware/sample/src/MiddlewareSample/Program.cs delete mode 100644 aspnet/fundamentals/middleware/sample/src/MiddlewareSample/hosting.ini diff --git a/aspnet/fundamentals/middleware.rst b/aspnet/fundamentals/middleware.rst index b3c76fd776..193011c108 100644 --- a/aspnet/fundamentals/middleware.rst +++ b/aspnet/fundamentals/middleware.rst @@ -168,7 +168,7 @@ For more complex request handling functionality, the ASP.NET team recommends imp .. literalinclude:: middleware/sample/src/MiddlewareSample/RequestLoggerMiddleware.cs :language: c# :caption: RequestLoggerMiddleware.cs - :emphasize-lines: 13, 19 + :emphasize-lines: 12, 18 The middleware follows the `Explicit Dependencies Principle `_ and exposes all of its dependencies in its constructor. Middleware can take advantage of the `UseMiddleware`_ extension to inject services directly into their constructors, as shown in the example below. Dependency injected services are automatically filled, and the extension takes a ``params`` array of arguments to be used for non-injected parameters. diff --git a/aspnet/fundamentals/middleware/sample/global.json b/aspnet/fundamentals/middleware/sample/global.json index 8f88a5ceb8..5e6422e6d6 100644 --- a/aspnet/fundamentals/middleware/sample/global.json +++ b/aspnet/fundamentals/middleware/sample/global.json @@ -1,6 +1,3 @@ { - "projects": [ "src", "test" ], -"sdk": { -"version": "1.0.0-beta6" -} + "projects": [ "src", "test" ] } diff --git a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/Program.cs b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/Program.cs new file mode 100644 index 0000000000..5c11881487 --- /dev/null +++ b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/Program.cs @@ -0,0 +1,20 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; + +namespace MiddlewareSample +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/RequestLoggerExtensions.cs b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/RequestLoggerExtensions.cs index 3073591064..d7f3ed6b55 100644 --- a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/RequestLoggerExtensions.cs +++ b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/RequestLoggerExtensions.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNet.Builder; +using Microsoft.AspNetCore.Builder; namespace MiddlewareSample { diff --git a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/RequestLoggerMiddleware.cs b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/RequestLoggerMiddleware.cs index f5992e2113..6c60abd454 100644 --- a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/RequestLoggerMiddleware.cs +++ b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/RequestLoggerMiddleware.cs @@ -1,7 +1,6 @@ -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.Framework.Logging; using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; namespace MiddlewareSample { diff --git a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/Startup.cs b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/Startup.cs index 6d9051f51f..02f5983b99 100644 --- a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/Startup.cs +++ b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/Startup.cs @@ -1,8 +1,8 @@ -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Http; -using Microsoft.Framework.DependencyInjection; -using Microsoft.Framework.Logging; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; namespace MiddlewareSample { diff --git a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/hosting.ini b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/hosting.ini deleted file mode 100644 index 126132d474..0000000000 --- a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/hosting.ini +++ /dev/null @@ -1,2 +0,0 @@ -server=Microsoft.AspNet.Server.WebListener -server.urls=http://localhost:5000 diff --git a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/project.json b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/project.json index f6fd08624f..1d77d4e72d 100644 --- a/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/project.json +++ b/aspnet/fundamentals/middleware/sample/src/MiddlewareSample/project.json @@ -1,34 +1,22 @@ { - "webroot": "wwwroot", "version": "1.0.0-*", - "dependencies": { - "Microsoft.AspNet.Server.IIS": "1.0.0-beta6", - "Microsoft.AspNet.Server.WebListener": "1.0.0-beta6", - "Microsoft.Framework.DependencyInjection": "1.0.0-beta6", - "Microsoft.Framework.Logging": "1.0.0-beta6", - "Microsoft.Framework.Logging.Console": "1.0.0-beta6" - }, + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, - "commands": { - "web": "Microsoft.AspNet.Hosting --config hosting.ini" + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", + "Microsoft.Extensions.DependencyInjection": "1.0.0", + "Microsoft.Extensions.Logging": "1.0.0", + "Microsoft.Extensions.Logging.Console": "1.0.0" }, "frameworks": { - "dnx451": { }, - "dnxcore50": { } + "netcoreapp1.0": {} }, - - "publishExclude": [ - "node_modules", - "bower_components", - "**.xproj", - "**.user", - "**.vspscc" - ], - "exclude": [ - "wwwroot", - "node_modules", - "bower_components" - ] + "buildOptions": { + "emitEntryPoint": true + } }