diff --git a/Mvc.sln b/Mvc.sln index b22ae18a96..0945d3557f 100644 --- a/Mvc.sln +++ b/Mvc.sln @@ -84,8 +84,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TagHel EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "PrecompilationWebSite", "test\WebSites\PrecompilationWebSite\PrecompilationWebSite.xproj", "{59E1BE90-92C1-4D35-ADCC-B69F49077C81}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RequestServicesWebSite", "test\WebSites\RequestServicesWebSite\RequestServicesWebSite.xproj", "{F12E9CF0-4958-40C6-A6CD-759185157F84}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RazorEmbeddedViewsWebSite", "test\WebSites\RazorEmbeddedViewsWebSite\RazorEmbeddedViewsWebSite.xproj", "{B18ADE62-35DE-4A06-8E1D-EDD6245F7F4D}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CompositeViewEngineWebSite", "test\WebSites\CompositeViewEngineWebSite\CompositeViewEngineWebSite.xproj", "{A853B2BA-4449-4908-A416-5A3C027FC22B}" @@ -528,16 +526,6 @@ Global {59E1BE90-92C1-4D35-ADCC-B69F49077C81}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {59E1BE90-92C1-4D35-ADCC-B69F49077C81}.Release|Mixed Platforms.Build.0 = Release|Any CPU {59E1BE90-92C1-4D35-ADCC-B69F49077C81}.Release|x86.ActiveCfg = Release|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Debug|x86.ActiveCfg = Debug|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Release|Any CPU.Build.0 = Release|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {F12E9CF0-4958-40C6-A6CD-759185157F84}.Release|x86.ActiveCfg = Release|Any CPU {B18ADE62-35DE-4A06-8E1D-EDD6245F7F4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B18ADE62-35DE-4A06-8E1D-EDD6245F7F4D}.Debug|Any CPU.Build.0 = Debug|Any CPU {B18ADE62-35DE-4A06-8E1D-EDD6245F7F4D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -1129,7 +1117,6 @@ Global {B2347320-308E-4D2B-AEC8-005DFA68B0C9} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {860119ED-3DB1-424D-8D0A-30132A8A7D96} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {59E1BE90-92C1-4D35-ADCC-B69F49077C81} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} - {F12E9CF0-4958-40C6-A6CD-759185157F84} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {B18ADE62-35DE-4A06-8E1D-EDD6245F7F4D} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {A853B2BA-4449-4908-A416-5A3C027FC22B} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {14F79E79-AE79-48FA-95DE-D794EF4EABB3} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/RequestServicesTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/RequestServicesTest.cs index 068d6421db..471a420602 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/RequestServicesTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/RequestServicesTest.cs @@ -11,9 +11,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests { // Each of these tests makes two requests, because we want each test to verify that the data is // PER-REQUEST and does not linger around to impact the next request. - public class RequestServicesTest : IClassFixture> + public class RequestServicesTest : IClassFixture> { - public RequestServicesTest(MvcTestFixture fixture) + public RequestServicesTest(MvcTestFixture fixture) { Client = fixture.Client; } @@ -21,11 +21,10 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests public HttpClient Client { get; } [Theory] - [InlineData("http://localhost/RequestScoped/FromController")] - [InlineData("http://localhost/Other/FromFilter")] - [InlineData("http://localhost/Other/FromView")] - [InlineData("http://localhost/Other/FromViewComponent")] - [InlineData("http://localhost/Other/FromActionArgument")] + [InlineData("http://localhost/RequestScopedService/FromFilter")] + [InlineData("http://localhost/RequestScopedService/FromView")] + [InlineData("http://localhost/RequestScopedService/FromViewComponent")] + [InlineData("http://localhost/RequestScopedService/FromActionArgument")] public async Task RequestServices(string url) { for (var i = 0; i < 2; i++) @@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests public async Task RequestServices_TagHelper() { // Arrange - var url = "http://localhost/Other/FromTagHelper"; + var url = "http://localhost/RequestScopedService/FromTagHelper"; // Act & Assert for (var i = 0; i < 2; i++) @@ -71,7 +70,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests public async Task RequestServices_ActionConstraint() { // Arrange - var url = "http://localhost/Other/FromActionConstraint"; + var url = "http://localhost/RequestScopedService/FromActionConstraint"; // Act & Assert var requestId1 = "b40f6ec1-8a6b-41c1-b3fe-928f581ebaf5"; diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json b/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json index 476efc77d8..ae441d980e 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json @@ -50,7 +50,6 @@ "RazorEmbeddedViewsWebSite": "1.0.0", "RazorPageExecutionInstrumentationWebSite": "1.0.0", "RazorWebSite": "1.0.0", - "RequestServicesWebSite": "1.0.0", "ResponseCacheWebSite": "1.0.0", "RoutingWebSite": "1.0.0", "TagHelperSample.Web": "1.0.0", diff --git a/test/WebSites/RequestServicesWebSite/Controllers/OtherController.cs b/test/WebSites/BasicWebSite/Controllers/RequestScopedServiceController.cs similarity index 89% rename from test/WebSites/RequestServicesWebSite/Controllers/OtherController.cs rename to test/WebSites/BasicWebSite/Controllers/RequestScopedServiceController.cs index e04a45bb89..5c95d8f149 100644 --- a/test/WebSites/RequestServicesWebSite/Controllers/OtherController.cs +++ b/test/WebSites/BasicWebSite/Controllers/RequestScopedServiceController.cs @@ -3,10 +3,10 @@ using Microsoft.AspNet.Mvc; -namespace RequestServicesWebSite +namespace BasicWebSite { - [Route("Other/[action]")] - public class OtherController : Controller + [Route("RequestScopedService/[action]")] + public class RequestScopedServiceController : Controller { // This only matches a specific requestId value [HttpGet] diff --git a/test/WebSites/RequestServicesWebSite/RequestIdMiddleware.cs b/test/WebSites/BasicWebSite/RequestIdMiddleware.cs similarity index 86% rename from test/WebSites/RequestServicesWebSite/RequestIdMiddleware.cs rename to test/WebSites/BasicWebSite/RequestIdMiddleware.cs index 47e7270ee6..e9f6114810 100644 --- a/test/WebSites/RequestServicesWebSite/RequestIdMiddleware.cs +++ b/test/WebSites/BasicWebSite/RequestIdMiddleware.cs @@ -3,11 +3,10 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.Extensions.DependencyInjection; -namespace RequestServicesWebSite +namespace BasicWebSite { // Initializes a scoped-service with a request Id from a header public class RequestIdMiddleware @@ -19,7 +18,7 @@ namespace RequestServicesWebSite _next = next; } - public async Task Invoke(HttpContext context) + public Task Invoke(HttpContext context) { var requestIdService = context.RequestServices.GetService(); if (requestIdService.RequestId != null) @@ -30,7 +29,7 @@ namespace RequestServicesWebSite var requestId = context.Request.Headers["RequestId"]; requestIdService.RequestId = requestId; - await _next(context); + return _next(context); } } } \ No newline at end of file diff --git a/test/WebSites/RequestServicesWebSite/RequestIdService.cs b/test/WebSites/BasicWebSite/RequestIdService.cs similarity index 95% rename from test/WebSites/RequestServicesWebSite/RequestIdService.cs rename to test/WebSites/BasicWebSite/RequestIdService.cs index 2c1cba0411..9d610ef582 100644 --- a/test/WebSites/RequestServicesWebSite/RequestIdService.cs +++ b/test/WebSites/BasicWebSite/RequestIdService.cs @@ -4,7 +4,7 @@ using System; using Microsoft.AspNet.Http; -namespace RequestServicesWebSite +namespace BasicWebSite { public class RequestIdService { diff --git a/test/WebSites/RequestServicesWebSite/RequestIdViewComponent.cs b/test/WebSites/BasicWebSite/RequestIdViewComponent.cs similarity index 94% rename from test/WebSites/RequestServicesWebSite/RequestIdViewComponent.cs rename to test/WebSites/BasicWebSite/RequestIdViewComponent.cs index 7beab6dbf5..bc817cf39a 100644 --- a/test/WebSites/RequestServicesWebSite/RequestIdViewComponent.cs +++ b/test/WebSites/BasicWebSite/RequestIdViewComponent.cs @@ -3,7 +3,7 @@ using Microsoft.AspNet.Mvc; -namespace RequestServicesWebSite +namespace BasicWebSite { public class RequestIdViewComponent : ViewComponent { diff --git a/test/WebSites/RequestServicesWebSite/RequestScopedActionConstraint.cs b/test/WebSites/BasicWebSite/RequestScopedActionConstraint.cs similarity index 96% rename from test/WebSites/RequestServicesWebSite/RequestScopedActionConstraint.cs rename to test/WebSites/BasicWebSite/RequestScopedActionConstraint.cs index 24dd280181..38d8de08e3 100644 --- a/test/WebSites/RequestServicesWebSite/RequestScopedActionConstraint.cs +++ b/test/WebSites/BasicWebSite/RequestScopedActionConstraint.cs @@ -3,11 +3,10 @@ using System; using System.Collections.Concurrent; -using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.ActionConstraints; using Microsoft.Extensions.DependencyInjection; -namespace RequestServicesWebSite +namespace BasicWebSite { // Only matches when the requestId is the same as the one passed in the constructor. public class RequestScopedActionConstraintAttribute : Attribute, IActionConstraintFactory diff --git a/test/WebSites/RequestServicesWebSite/RequestScopedFilter.cs b/test/WebSites/BasicWebSite/RequestScopedFilter.cs similarity index 96% rename from test/WebSites/RequestServicesWebSite/RequestScopedFilter.cs rename to test/WebSites/BasicWebSite/RequestScopedFilter.cs index d2b5d90be9..3dbf197363 100644 --- a/test/WebSites/RequestServicesWebSite/RequestScopedFilter.cs +++ b/test/WebSites/BasicWebSite/RequestScopedFilter.cs @@ -5,7 +5,7 @@ using System; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.Filters; -namespace RequestServicesWebSite +namespace BasicWebSite { public class RequestScopedFilter : IActionFilter { diff --git a/test/WebSites/RequestServicesWebSite/RequestScopedTagHelper.cs b/test/WebSites/BasicWebSite/RequestScopedTagHelper.cs similarity index 93% rename from test/WebSites/RequestServicesWebSite/RequestScopedTagHelper.cs rename to test/WebSites/BasicWebSite/RequestScopedTagHelper.cs index e262bcb5a4..c4ef85a06d 100644 --- a/test/WebSites/RequestServicesWebSite/RequestScopedTagHelper.cs +++ b/test/WebSites/BasicWebSite/RequestScopedTagHelper.cs @@ -3,7 +3,7 @@ using Microsoft.AspNet.Razor.TagHelpers; -namespace RequestServicesWebSite +namespace BasicWebSite { public class RequestScopedTagHelper : TagHelper { @@ -11,7 +11,7 @@ namespace RequestServicesWebSite { RequestIdService = service; } - + public RequestIdService RequestIdService { get; } public override void Process(TagHelperContext context, TagHelperOutput output) diff --git a/test/WebSites/BasicWebSite/Startup.cs b/test/WebSites/BasicWebSite/Startup.cs index 1a619ac3c3..956778ed4c 100644 --- a/test/WebSites/BasicWebSite/Startup.cs +++ b/test/WebSites/BasicWebSite/Startup.cs @@ -18,12 +18,17 @@ namespace BasicWebSite }); services.AddLogging(); services.AddSingleton(); + + services.AddScoped(); } public void Configure(IApplicationBuilder app) { app.UseCultureReplacer(); + // Initializes the RequestId service for each request + app.UseMiddleware(); + // Add MVC to the request pipeline app.UseMvc(routes => { diff --git a/test/WebSites/BasicWebSite/Views/RequestScopedService/TagHelper.cshtml b/test/WebSites/BasicWebSite/Views/RequestScopedService/TagHelper.cshtml new file mode 100644 index 0000000000..5e597fcb9e --- /dev/null +++ b/test/WebSites/BasicWebSite/Views/RequestScopedService/TagHelper.cshtml @@ -0,0 +1,3 @@ +@using BasicWebSite +@addTagHelper BasicWebSite.RequestScopedTagHelper, BasicWebSite + \ No newline at end of file diff --git a/test/WebSites/BasicWebSite/Views/RequestScopedService/View.cshtml b/test/WebSites/BasicWebSite/Views/RequestScopedService/View.cshtml new file mode 100644 index 0000000000..5b1982dc93 --- /dev/null +++ b/test/WebSites/BasicWebSite/Views/RequestScopedService/View.cshtml @@ -0,0 +1,3 @@ +@using BasicWebSite +@inject RequestIdService RequestIdService +@RequestIdService.RequestId \ No newline at end of file diff --git a/test/WebSites/RequestServicesWebSite/Views/Other/ViewComponent.cshtml b/test/WebSites/BasicWebSite/Views/RequestScopedService/ViewComponent.cshtml similarity index 100% rename from test/WebSites/RequestServicesWebSite/Views/Other/ViewComponent.cshtml rename to test/WebSites/BasicWebSite/Views/RequestScopedService/ViewComponent.cshtml diff --git a/test/WebSites/RequestServicesWebSite/Controllers/RequestScopedServiceController.cs b/test/WebSites/RequestServicesWebSite/Controllers/RequestScopedServiceController.cs deleted file mode 100644 index f79b55eb09..0000000000 --- a/test/WebSites/RequestServicesWebSite/Controllers/RequestScopedServiceController.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNet.Mvc; - -namespace RequestServicesWebSite -{ - [Route("RequestScoped/[action]")] - public class RequestScopedServiceController - { - [HttpGet] - public string FromController([FromServices] RequestIdService requestIdService) - { - return requestIdService.RequestId; - } - } -} \ No newline at end of file diff --git a/test/WebSites/RequestServicesWebSite/RequestServicesWebSite.xproj b/test/WebSites/RequestServicesWebSite/RequestServicesWebSite.xproj deleted file mode 100644 index 5ce0b14580..0000000000 --- a/test/WebSites/RequestServicesWebSite/RequestServicesWebSite.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - f12e9cf0-4958-40c6-a6cd-759185157f84 - ..\..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - 40959 - - - \ No newline at end of file diff --git a/test/WebSites/RequestServicesWebSite/Startup.cs b/test/WebSites/RequestServicesWebSite/Startup.cs deleted file mode 100644 index 1c8bb28120..0000000000 --- a/test/WebSites/RequestServicesWebSite/Startup.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Internal; -using Microsoft.Extensions.DependencyInjection; - -namespace RequestServicesWebSite -{ - public class Startup - { - // Set up application services - public void ConfigureServices(IServiceCollection services) - { - services.AddMvc(); - - services.AddScoped(); - services.AddSingleton(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseCultureReplacer(); - - // Initializes the RequestId service for each request - app.UseMiddleware(); - - app.UseMvcWithDefaultRoute(); - } - } -} diff --git a/test/WebSites/RequestServicesWebSite/Views/Other/TagHelper.cshtml b/test/WebSites/RequestServicesWebSite/Views/Other/TagHelper.cshtml deleted file mode 100644 index 0b4790cfee..0000000000 --- a/test/WebSites/RequestServicesWebSite/Views/Other/TagHelper.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@using RequestServicesWebSite -@addTagHelper RequestServicesWebSite.RequestScopedTagHelper, RequestServicesWebSite - \ No newline at end of file diff --git a/test/WebSites/RequestServicesWebSite/Views/Other/View.cshtml b/test/WebSites/RequestServicesWebSite/Views/Other/View.cshtml deleted file mode 100644 index dbd7c419b4..0000000000 --- a/test/WebSites/RequestServicesWebSite/Views/Other/View.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@using RequestServicesWebSite -@inject RequestIdService RequestIdService -@RequestIdService.RequestId \ No newline at end of file diff --git a/test/WebSites/RequestServicesWebSite/project.json b/test/WebSites/RequestServicesWebSite/project.json deleted file mode 100644 index 7cfdbb4f85..0000000000 --- a/test/WebSites/RequestServicesWebSite/project.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "webroot": "wwwroot", - "exclude": "wwwroot/**/*", - "commands": { - "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001", - "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000" - }, - "dependencies": { - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.Mvc": "6.0.0-*", - "Microsoft.AspNet.Mvc.TestConfiguration": "1.0.0", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", - "Microsoft.AspNet.StaticFiles": "1.0.0-*" - }, - "frameworks": { - "dnx451": { }, - "dnxcore50": { } - } -} diff --git a/test/WebSites/RequestServicesWebSite/readme.md b/test/WebSites/RequestServicesWebSite/readme.md deleted file mode 100644 index d23aa4b0f0..0000000000 --- a/test/WebSites/RequestServicesWebSite/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -RequestServicesWebSite -=== - -This web site registers services which are scoped per request. This web site is used for functional testing -to ensure that the services are per-request and does not linger around to impact the next request. diff --git a/test/WebSites/RequestServicesWebSite/wwwroot/HelloWorld.htm b/test/WebSites/RequestServicesWebSite/wwwroot/HelloWorld.htm deleted file mode 100644 index 3da1ec26e9..0000000000 --- a/test/WebSites/RequestServicesWebSite/wwwroot/HelloWorld.htm +++ /dev/null @@ -1 +0,0 @@ -HelloWorld