154 writes to HttpContext
Microsoft.AspNetCore.Mvc.Abstractions (1)
ActionContext.cs (1)
72HttpContext = httpContext;
Microsoft.AspNetCore.Mvc.Core.Test (86)
ControllerBaseTest.cs (8)
1864controller.ControllerContext.HttpContext = mockHttpContext.Object; 1891controller.ControllerContext.HttpContext = mockHttpContext.Object; 1917controller.ControllerContext.HttpContext = mockHttpContext.Object; 1943controller.ControllerContext.HttpContext = mockHttpContext.Object; 2998controller.ControllerContext.HttpContext = httpContext.Object; 3018controller.ControllerContext.HttpContext = httpContext.Object; 3038controller.ControllerContext.HttpContext = httpContext.Object; 3216HttpContext = httpContext,
Controllers\ControllerActivatorProviderTest.cs (1)
54HttpContext = new DefaultHttpContext
Controllers\ControllerBinderDelegateProviderTest.cs (1)
1257HttpContext = new DefaultHttpContext()
Controllers\DefaultControllerFactoryTest.cs (6)
28HttpContext = new DefaultHttpContext() 62HttpContext = new DefaultHttpContext() 89HttpContext = new DefaultHttpContext() 116HttpContext = new DefaultHttpContext() 143HttpContext = new DefaultHttpContext() 171HttpContext = new DefaultHttpContext()
DependencyInjection\ApiBehaviorOptionsSetupTest.cs (1)
148HttpContext = new DefaultHttpContext { TraceIdentifier = "42" },
FileResultHelperTest.cs (4)
265actionContext.HttpContext = httpContext; 304actionContext.HttpContext = httpContext; 341actionContext.HttpContext = httpContext; 369actionContext.HttpContext = httpContext;
HttpNotFoundObjectResultTest.cs (1)
43HttpContext = httpContext,
Infrastructure\ControllerActionInvokerProviderTest.cs (1)
30HttpContext = new DefaultHttpContext(),
Infrastructure\FileStreamResultExecutorTest.cs (1)
18var actionContext = new ActionContext() { HttpContext = httpContext };
Infrastructure\ObjectResultExecutorTest.cs (17)
25var actionContext = new ActionContext() { HttpContext = httpContext }; 53var actionContext = new ActionContext() { HttpContext = httpContext }; 76var actionContext = new ActionContext() { HttpContext = httpContext }; 98var actionContext = new ActionContext() { HttpContext = httpContext }; 119var actionContext = new ActionContext() { HttpContext = httpContext }; 144var actionContext = new ActionContext() { HttpContext = httpContext }; 166var actionContext = new ActionContext() { HttpContext = httpContext }; 188var actionContext = new ActionContext() { HttpContext = httpContext }; 214var actionContext = new ActionContext() { HttpContext = httpContext }; 239var actionContext = new ActionContext() { HttpContext = httpContext }; 261HttpContext = GetHttpContext(), 290HttpContext = GetHttpContext(), 313HttpContext = GetHttpContext(), 347var actionContext = new ActionContext() { HttpContext = new DefaultHttpContext() }; 387HttpContext = GetHttpContext(), 424HttpContext = GetHttpContext(), 447HttpContext = GetHttpContext(),
Infrastructure\ProblemDetalsClientErrorFactoryTest.cs (1)
124HttpContext = new DefaultHttpContext
ModelBinding\Binders\ArrayModelBinderTest.cs (1)
233HttpContext = new DefaultHttpContext(),
ModelBinding\Binders\BinderTypeModelBinderTest.cs (1)
77HttpContext = new DefaultHttpContext() { RequestServices = new ServiceCollection().BuildServiceProvider() },
ModelBinding\Binders\BodyModelBinderTests.cs (1)
693HttpContext = httpContext,
ModelBinding\Binders\CancellationTokenModelBinderTests.cs (1)
33HttpContext = new DefaultHttpContext(),
ModelBinding\Binders\CollectionModelBinderTest.cs (1)
533HttpContext = new DefaultHttpContext(),
ModelBinding\Binders\ComplexObjectModelBinderTest.cs (5)
468HttpContext = new DefaultHttpContext() 495HttpContext = new DefaultHttpContext() 523HttpContext = new DefaultHttpContext(), 550HttpContext = new DefaultHttpContext() 576HttpContext = new DefaultHttpContext(),
ModelBinding\Binders\ComplexTypeModelBinderTest.cs (5)
649HttpContext = new DefaultHttpContext() 676HttpContext = new DefaultHttpContext() 704HttpContext = new DefaultHttpContext(), 731HttpContext = new DefaultHttpContext() 757HttpContext = new DefaultHttpContext(),
ModelBinding\Binders\DictionaryModelBinderTest.cs (1)
624HttpContext = new DefaultHttpContext(),
ModelBinding\Binders\FormCollectionModelBinderTest.cs (1)
73HttpContext = httpContext,
ModelBinding\Binders\FormFileModelBinderTest.cs (6)
52new ActionContext { HttpContext = httpContext }, 90new ActionContext { HttpContext = httpContext }, 132new ActionContext { HttpContext = httpContext }, 167new ActionContext { HttpContext = httpContext }, 203new ActionContext { HttpContext = httpContext }, 461HttpContext = httpContext,
ModelBinding\Binders\HeaderModelBinderTests.cs (1)
364HttpContext = new DefaultHttpContext()
ModelBinding\Binders\KeyValuePairModelBinderTest.cs (1)
205HttpContext = new DefaultHttpContext(),
ModelBinding\Binders\ServicesModelBinderTest.cs (1)
46HttpContext = new DefaultHttpContext()
ModelBinding\DefaultModelBindingContextTest.cs (1)
162HttpContext = new DefaultHttpContext()
ModelBinding\ModelBindingHelperTest.cs (1)
1500HttpContext = new DefaultHttpContext()
ModelBinding\ParameterBinderTest.cs (1)
711HttpContext = new DefaultHttpContext()
ModelBinding\UnsupportedContentTypeFilterTest.cs (4)
20HttpContext = new DefaultHttpContext(), 53HttpContext = new DefaultHttpContext(), 79HttpContext = new DefaultHttpContext(), 103HttpContext = new DefaultHttpContext(),
ModelBinding\Validation\DefaultObjectValidatorTests.cs (1)
587var actionContext = new ActionContext { HttpContext = httpContext.Object };
ObjectResultTests.cs (4)
49HttpContext = new DefaultHttpContext() 81HttpContext = new DefaultHttpContext() 110HttpContext = new DefaultHttpContext() 141HttpContext = new DefaultHttpContext()
RedirectToPageResultTest.cs (2)
86HttpContext = httpContext, 143HttpContext = httpContext,
Routing\UrlHelperExtensionsTest.cs (3)
717HttpContext = new DefaultHttpContext 765HttpContext = new DefaultHttpContext 813HttpContext = new DefaultHttpContext
Routing\UrlHelperTestBase.cs (1)
1084HttpContext = new DefaultHttpContext()
Microsoft.AspNetCore.Mvc.DataAnnotations.Test (1)
DataAnnotationsModelValidatorTest.cs (1)
425HttpContext = httpContext.Object
Microsoft.AspNetCore.Mvc.IntegrationTests (2)
BindPropertyIntegrationTest.cs (1)
230HttpContext = testContext.HttpContext,
ModelBindingTestHelper.cs (1)
36HttpContext = httpContext,
Microsoft.AspNetCore.Mvc.Razor.Test (4)
TagHelpers\UrlResolutionTagHelperTest.cs (4)
115ViewContext = new Rendering.ViewContext { HttpContext = new DefaultHttpContext() } 175ViewContext = new Rendering.ViewContext { HttpContext = new DefaultHttpContext() } 369ViewContext = new Rendering.ViewContext { HttpContext = new DefaultHttpContext() } 415ViewContext = new Rendering.ViewContext { HttpContext = httpContext }
Microsoft.AspNetCore.Mvc.RazorPages.Test (48)
ApplicationModels\DefaultPageApplicationModelProviderTest.cs (1)
990HttpContext = new DefaultHttpContext
Filters\PageSaveTempDataPropertyFilterTest.cs (3)
62HttpContext = httpContext, 103HttpContext = httpContext, 143HttpContext = httpContext,
Infrastructure\DefaultPageFactoryProviderTest.cs (7)
229HttpContext = pageContext.HttpContext, 260HttpContext = new DefaultHttpContext 268HttpContext = pageContext.HttpContext, 303HttpContext = new DefaultHttpContext 311HttpContext = pageContext.HttpContext, 341HttpContext = new DefaultHttpContext 349HttpContext = pageContext.HttpContext,
Infrastructure\DefaultPageHandlerMethodSelectorTest.cs (15)
37HttpContext = new DefaultHttpContext 85HttpContext = new DefaultHttpContext 136HttpContext = new DefaultHttpContext 180HttpContext = new DefaultHttpContext 216HttpContext = new DefaultHttpContext 259HttpContext = new DefaultHttpContext 309HttpContext = new DefaultHttpContext 359HttpContext = new DefaultHttpContext 410HttpContext = new DefaultHttpContext 454HttpContext = new DefaultHttpContext 505HttpContext = new DefaultHttpContext 550HttpContext = new DefaultHttpContext 600HttpContext = new DefaultHttpContext 650HttpContext = new DefaultHttpContext 710HttpContext = new DefaultHttpContext
Infrastructure\DefaultPageModelActivatorProviderTest.cs (2)
48HttpContext = httpContext 78HttpContext = httpContext
Infrastructure\PageActionInvokerProviderTest.cs (9)
56HttpContext = new DefaultHttpContext(), 118HttpContext = new DefaultHttpContext(), 184HttpContext = new DefaultHttpContext(), 216HttpContext = new DefaultHttpContext(), 232HttpContext = new DefaultHttpContext(), 262HttpContext = new DefaultHttpContext(), 296HttpContext = new DefaultHttpContext(), 333HttpContext = new DefaultHttpContext(), 350HttpContext = new DefaultHttpContext(),
Infrastructure\PageActionInvokerTest.cs (1)
1507HttpContext = httpContext,
Infrastructure\PageBinderFactoryTest.cs (1)
800HttpContext = httpContext
Infrastructure\ServiceBasedPageModelActivatorProviderTest.cs (3)
40HttpContext = new DefaultHttpContext 72HttpContext = new DefaultHttpContext 106HttpContext = httpContext,
PageModelTest.cs (4)
1450HttpContext = mockHttpContext.Object 1476HttpContext = mockHttpContext.Object 1794HttpContext = httpContext, 1798HttpContext = httpContext,
PageTest.cs (2)
1440HttpContext = mockHttpContext.Object 1466HttpContext = mockHttpContext.Object
Microsoft.AspNetCore.Mvc.TagHelpers.Test (4)
ComponentTagHelperTest.cs (1)
97return new ViewContext { HttpContext = httpContext };
DefaultTagHelperActivatorTest.cs (1)
68HttpContext = new DefaultHttpContext
ImageTagHelperTest.cs (1)
196helper.ViewContext.HttpContext = new DefaultHttpContext();
PersistComponentStateTagHelperTest.cs (1)
268return new ViewContext { HttpContext = httpContext };
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (8)
ControllerTest.cs (1)
447HttpContext = httpContext,
ControllerUnitTestabilityTests.cs (2)
162controller.ControllerContext.HttpContext = mockHttpContext.Object; 601HttpContext = httpContext,
Filters\ControllerSaveTempDataPropertyFilterTest.cs (4)
41HttpContext = httpContext, 87HttpContext = httpContext, 130HttpContext = httpContext, 169HttpContext = httpContext,
ViewComponents\DefaultViewComponentActivatorTests.cs (1)
91HttpContext = new DefaultHttpContext
613 references to HttpContext
BasicWebSite (10)
Controllers\TestingController.cs (2)
108context.HttpContext.Response.Redirect(_url); 109context.HttpContext.Response.StatusCode = (int)_statusCode;
Filters\ServiceActionFilter.cs (1)
24context.HttpContext.Response.Headers["X-ServiceActionFilter"] = "True";
Filters\TestExceptionFilter.cs (1)
13if (context.HttpContext.Request.Query.TryGetValue("handleException", out var handleException))
Filters\TraceOutputResultFilter.cs (1)
13var trace = context.HttpContext.Items[nameof(TraceResourceFilter)];
Filters\TraceResourceFilter.cs (1)
16context.HttpContext.Items[nameof(TraceResourceFilter)] = $"This value was set by {nameof(TraceResourceFilter)}";
src\Mvc\test\WebSites\Common\TestResponseGenerator.cs (3)
27var query = _actionContext.HttpContext.Request.Query; 43actualUrl = _actionContext.HttpContext.Request.Path.Value, 56var services = context.HttpContext.RequestServices;
StoreIntoTempDataActionResult.cs (1)
14var httpContext = context.HttpContext;
ControllersFromServicesClassLibrary (1)
ControllerWithConstructorInjection.cs (1)
33ActionContext.HttpContext.Request.Headers["Test-Header"]);
GenericHostWebSite (5)
Controllers\TestingController.cs (2)
94context.HttpContext.Response.Redirect(_url); 95context.HttpContext.Response.StatusCode = (int)_statusCode;
src\Mvc\test\WebSites\Common\TestResponseGenerator.cs (3)
27var query = _actionContext.HttpContext.Request.Query; 43actualUrl = _actionContext.HttpContext.Request.Path.Value, 56var services = context.HttpContext.RequestServices;
Microsoft.AspNetCore.Identity.UI (1)
Areas\Identity\Filters\ExternalLoginsPageFilter.cs (1)
18var signInManager = context.HttpContext.RequestServices.GetRequiredService<SignInManager<TUser>>();
Microsoft.AspNetCore.Mvc.Abstractions (2)
ActionContext.cs (1)
33actionContext.HttpContext,
ModelBinding\ModelBindingContext.cs (1)
41public virtual HttpContext HttpContext => ActionContext?.HttpContext!;
Microsoft.AspNetCore.Mvc.Core (119)
AcceptedAtActionResult.cs (3)
69var request = context.HttpContext.Request; 74var services = context.HttpContext.RequestServices; 90context.HttpContext.Response.Headers.Location = url;
AcceptedAtRouteResult.cs (2)
75var services = context.HttpContext.RequestServices; 86context.HttpContext.Response.Headers.Location = url;
AcceptedResult.cs (1)
77context.HttpContext.Response.Headers.Location = Location;
ApplicationModels\DefaultApplicationModelProvider.cs (1)
35_supportsNonGetRequests = context => !HttpMethods.IsGet(context.HttpContext.Request.Method);
Authorization\AuthorizeFilter.cs (6)
137var endpoint = context.HttpContext.GetEndpoint(); 145var policyProvider = PolicyProvider ?? context.HttpContext.RequestServices.GetRequiredService<IAuthorizationPolicyProvider>(); 175var policyEvaluator = context.HttpContext.RequestServices.GetRequiredService<IPolicyEvaluator>(); 177var authenticateResult = await policyEvaluator.AuthenticateAsync(effectivePolicy, context.HttpContext); 185var authorizeResult = await policyEvaluator.AuthorizeAsync(effectivePolicy, authenticateResult, context.HttpContext, context); 224var endpoint = context.HttpContext.GetEndpoint();
BindPropertyAttribute.cs (1)
86return !HttpMethods.IsGet(context.HttpContext.Request.Method);
ChallengeResult.cs (1)
95var httpContext = context.HttpContext;
ConsumesAttribute.cs (1)
114var requestContentType = context.HttpContext.Request.ContentType;
ContentResult.cs (1)
35var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ContentResult>>();
ControllerBase.cs (1)
37public HttpContext HttpContext => ControllerContext.HttpContext;
Controllers\ControllerActivatorProvider.cs (1)
59return controllerContext => typeActivator(controllerContext.HttpContext.RequestServices, arguments: null);
Controllers\DefaultControllerActivator.cs (1)
48var serviceProvider = controllerContext.HttpContext.RequestServices;
Controllers\ServiceBasedControllerActivator.cs (1)
21return actionContext.HttpContext.RequestServices.GetRequiredService(controllerType);
CreatedAtActionResult.cs (3)
69var request = context.HttpContext.Request; 74var services = context.HttpContext.RequestServices; 90context.HttpContext.Response.Headers.Location = url;
CreatedAtRouteResult.cs (2)
75var services = context.HttpContext.RequestServices; 86context.HttpContext.Response.Headers.Location = url;
CreatedResult.cs (1)
85context.HttpContext.Response.Headers.Location = Location;
DependencyInjection\ApiBehaviorOptionsSetup.cs (2)
23_problemDetailsFactory ??= context.HttpContext.RequestServices.GetRequiredService<ProblemDetailsFactory>(); 32var problemDetails = problemDetailsFactory.CreateValidationProblemDetails(context.HttpContext, context.ModelState);
FileContentResult.cs (1)
66var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<FileContentResult>>();
FileStreamResult.cs (1)
67var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<FileStreamResult>>();
Filters\DefaultFilterProvider.cs (1)
51var services = context.ActionContext.HttpContext.RequestServices;
Filters\DisableRequestSizeLimitFilter.cs (1)
43var maxRequestBodySizeFeature = context.HttpContext.Features.Get<IHttpMaxRequestBodySizeFeature>();
Filters\MiddlewareFilter.cs (1)
24var httpContext = context.HttpContext;
Filters\OutputCacheFilter.cs (1)
39var outputCachingFeature = context.HttpContext.Features.Get<IOutputCacheFeature>();
Filters\RequestFormLimitsFilter.cs (2)
34var features = context.HttpContext.Features; 40features.Set<IFormFeature>(new FormFeature(context.HttpContext.Request, FormOptions));
Filters\RequestSizeLimitFilter.cs (1)
45var maxRequestBodySizeFeature = context.HttpContext.Features.Get<IHttpMaxRequestBodySizeFeature>();
Filters\ResponseCacheFilterExecutor.cs (2)
69var headers = context.HttpContext.Response.Headers; 83var responseCachingFeature = context.HttpContext.Features.Get<IResponseCachingFeature>();
ForbidResult.cs (1)
95var httpContext = context.HttpContext;
Formatters\FormatFilter.cs (2)
46var query = context.HttpContext.Request.Query["format"]; 151!string.IsNullOrEmpty(context.HttpContext.Response.ContentType))
HttpActionResult.cs (1)
30=> Result.ExecuteAsync(context.HttpContext);
Infrastructure\ContentResultExecutor.cs (1)
39var response = context.HttpContext.Response;
Infrastructure\ControllerEndpointFilterInvocationContext.cs (1)
40public override HttpContext HttpContext => ActionContext.HttpContext;
Infrastructure\FileContentResultExecutor.cs (1)
72return WriteFileAsync(context.HttpContext, fileContentStream, range, rangeLength);
Infrastructure\FileResultExecutorBase.cs (1)
70return FileResultHelper.SetHeadersAndLog(context.HttpContext, fileResultInfo, fileLength, enableRangeProcessing, lastModified, etag, Logger);
Infrastructure\FileStreamResultExecutor.cs (1)
84return WriteFileAsync(context.HttpContext, result.FileStream, range, rangeLength);
Infrastructure\LocalRedirectResultExecutor.cs (3)
54context.HttpContext.Response.StatusCode = result.Permanent ? 56context.HttpContext.Response.Headers.Location = destinationUrl; 60context.HttpContext.Response.Redirect(destinationUrl, result.Permanent);
Infrastructure\ObjectResultExecutor.cs (5)
86context.HttpContext, 102context.HttpContext.Response.StatusCode = statusCode; 104if (context.HttpContext.RequestServices.GetService<IProblemDetailsService>() is { } problemDetailsService) 108HttpContext = context.HttpContext, 128var responseContentType = context.HttpContext.Response.ContentType;
Infrastructure\PhysicalFileResultExecutor.cs (1)
60return WriteFileAsyncInternal(context.HttpContext, result, range, rangeLength, Logger);
Infrastructure\ProblemDetailsClientErrorFactory.cs (1)
17var problemDetails = _problemDetailsFactory.CreateProblemDetails(actionContext.HttpContext, clientError.StatusCode);
Infrastructure\RedirectResultExecutor.cs (3)
51context.HttpContext.Response.StatusCode = result.Permanent ? 53context.HttpContext.Response.Headers.Location = destinationUrl; 57context.HttpContext.Response.Redirect(destinationUrl, result.Permanent);
Infrastructure\RedirectToActionResultExecutor.cs (3)
57context.HttpContext.Response.StatusCode = result.Permanent ? 59context.HttpContext.Response.Headers.Location = destinationUrl; 63context.HttpContext.Response.Redirect(destinationUrl, result.Permanent);
Infrastructure\RedirectToPageResultExecutor.cs (3)
57context.HttpContext.Response.StatusCode = result.Permanent ? 59context.HttpContext.Response.Headers.Location = destinationUrl; 63context.HttpContext.Response.Redirect(destinationUrl, result.Permanent);
Infrastructure\RedirectToRouteResultExecutor.cs (3)
53context.HttpContext.Response.StatusCode = result.Permanent ? 55context.HttpContext.Response.Headers.Location = destinationUrl; 59context.HttpContext.Response.Redirect(destinationUrl, result.Permanent);
Infrastructure\ResourceInvoker.cs (2)
106actionContext.HttpContext, 136actionContext.HttpContext,
Infrastructure\SystemTextJsonResultExecutor.cs (6)
41var response = context.HttpContext.Response; 69await JsonSerializer.SerializeAsync(responseWriter, value, objectType, jsonSerializerOptions, context.HttpContext.RequestAborted); 71catch (OperationCanceledException) when (context.HttpContext.RequestAborted.IsCancellationRequested) { } 82await JsonSerializer.SerializeAsync(transcodingStream, value, objectType, jsonSerializerOptions, context.HttpContext.RequestAborted); 83await transcodingStream.FlushAsync(context.HttpContext.RequestAborted); 85catch (OperationCanceledException) when (context.HttpContext.RequestAborted.IsCancellationRequested)
Infrastructure\VirtualFileResultExecutor.cs (1)
71return WriteFileAsyncInternal(context.HttpContext, fileInfo, range, rangeLength, Logger);
JsonResult.cs (1)
74var services = context.HttpContext.RequestServices;
LocalRedirectResult.cs (1)
91var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<LocalRedirectResult>>();
ModelBinding\DefaultModelBindingContext.cs (1)
235var mvcOptions = actionContext.HttpContext.RequestServices?.GetService<IOptions<MvcOptions>>();
ModelBinding\FormFileValueProviderFactory.cs (1)
21var request = context.ActionContext.HttpContext.Request;
ModelBinding\FormValueProviderFactory.cs (2)
22var request = context.ActionContext.HttpContext.Request; 34var request = context.ActionContext.HttpContext.Request;
ModelBinding\JQueryFormValueProviderFactory.cs (2)
22var request = context.ActionContext.HttpContext.Request; 34var request = context.ActionContext.HttpContext.Request;
ModelBinding\JQueryQueryStringValueProviderFactory.cs (1)
20var query = context.ActionContext.HttpContext.Request.Query;
ModelBinding\QueryStringValueProviderFactory.cs (1)
21var query = context.ActionContext.HttpContext.Request.Query;
ObjectResult.cs (2)
62var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<ObjectResult>>(); 87context.HttpContext.Response.StatusCode = StatusCode.Value;
PhysicalFileResult.cs (1)
58var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<PhysicalFileResult>>();
RedirectResult.cs (1)
93var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<RedirectResult>>();
RedirectToActionResult.cs (1)
171var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<RedirectToActionResult>>();
RedirectToPageResult.cs (1)
209var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<RedirectToPageResult>>();
RedirectToRouteResult.cs (1)
163var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<RedirectToRouteResult>>();
RequireHttpsAttribute.cs (4)
45if (!filterContext.HttpContext.Request.IsHttps) 66if (!HttpMethods.IsGet(filterContext.HttpContext.Request.Method)) 72var optionsAccessor = filterContext.HttpContext.RequestServices.GetRequiredService<IOptions<MvcOptions>>(); 74var request = filterContext.HttpContext.Request;
Routing\EndpointRoutingUrlHelper.cs (2)
69ActionContext.HttpContext, 82ActionContext.HttpContext,
Routing\UrlHelper.cs (1)
28protected HttpContext HttpContext => ActionContext.HttpContext;
Routing\UrlHelperBase.cs (7)
51public virtual string? Content(string? contentPath) => Content(ActionContext.HttpContext, contentPath); 60Protocol = ActionContext.HttpContext.Request.Scheme, 61Host = ActionContext.HttpContext.Request.Host.ToUriComponent() 131var pathBase = ActionContext.HttpContext.Request.PathBase; 149host = string.IsNullOrEmpty(host) ? ActionContext.HttpContext.Request.Host.Value : host; 211host = string.IsNullOrEmpty(host) ? ActionContext.HttpContext.Request.Host.Value : host; 470var pathBase = ActionContext.HttpContext.Request.PathBase;
Routing\UrlHelperFactory.cs (2)
21var httpContext = context.HttpContext; 26nameof(ActionContext.HttpContext),
SignInResult.cs (1)
82var httpContext = context.HttpContext;
SignOutResult.cs (1)
94return ExecuteAsync(context.HttpContext);
StatusCodeResult.cs (1)
38var httpContext = context.HttpContext;
UrlHelperExtensions.cs (2)
525var httpContext = helper.ActionContext.HttpContext; 574var httpContext = urlHelper.ActionContext.HttpContext;
VirtualFileResult.cs (1)
64var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<VirtualFileResult>>();
Microsoft.AspNetCore.Mvc.Core.Test (119)
AcceptedAtActionResultTests.cs (2)
202context.HttpContext.RequestServices = new ForwardingServiceProvider(); 209var header = context.HttpContext.Response.Headers.Last();
Authorization\AuthorizeFilterTest.cs (6)
27Assert.Contains(authorizationContext.HttpContext.User.Identities, i => i.IsAuthenticated); 42authorizationContext.HttpContext.RequestServices); 90authorizationContext.HttpContext.User = new ClaimsPrincipal(); 214Assert.NotNull(authorizationContext.HttpContext.User?.Identity); 552ActionContext.HttpContext.RequestServices = new ServiceCollection() 556ActionContext.HttpContext.SetEndpoint(new Endpoint(
Controllers\ControllerBinderDelegateProviderTest.cs (2)
808controllerContext.HttpContext.Request.Method = "GET"; 871controllerContext.HttpContext.Request.Method = "POST";
FileResultHelperTest.cs (1)
499var executor = context.HttpContext.RequestServices.GetRequiredService<EmptyFileResultExecutor>();
Filters\DisableRequestSizeLimitFilterTest.cs (4)
23authorizationFilterContext.HttpContext.Features.Set<IHttpMaxRequestBodySizeFeature>(httpMaxRequestBodySize); 42authorizationFilterContext.HttpContext.Features.Set<IHttpMaxRequestBodySizeFeature>(httpMaxRequestBodySize); 84authorizationFilterContext.HttpContext.Features.Set<IHttpMaxRequestBodySizeFeature>(httpMaxRequestBodySize); 105authorizationFilterContext.HttpContext.Features.Set<IHttpMaxRequestBodySizeFeature>(httpMaxRequestBodySize);
Filters\FilterFactoryTest.cs (3)
213var filter = new TestFilter(providerContext.ActionContext.HttpContext.Items["name"] as string); 231actionContext.HttpContext.Items["name"] = "foo"; 243actionContext.HttpContext.Items["name"] = "bar";
Filters\MiddlewareFilterTest.cs (6)
40var feature = resourceExecutingContext.HttpContext.Features.Get<IMiddlewareFilterFeature>(); 77Assert.True(resourceExecutedContext.HttpContext.Response.Headers.ContainsKey(expectedHeader)); 125var response = resourceExecutedContext.HttpContext.Response; 211var response = resourceExecutedContext.HttpContext.Response; 499context.HttpContext.Response.StatusCode = 200; 500return context.HttpContext.Response.WriteAsync("Shortcircuited");
Filters\RequestFormLimitsFilterTest.cs (9)
25authorizationFilterContext.HttpContext.Features.Set<IFormFeature>(null); 31var formFeature = authorizationFilterContext.HttpContext.Features.Get<IFormFeature>(); 43var oldFormFeature = new FormFeature(authorizationFilterContext.HttpContext.Request); 45authorizationFilterContext.HttpContext.Features.Set<IFormFeature>(oldFormFeature); 51var actualFormFeature = authorizationFilterContext.HttpContext.Features.Get<IFormFeature>(); 66authorizationFilterContext.HttpContext.Request.Form = new FormCollection(null); 91authorizationFilterContext.HttpContext.Features.Set<IFormFeature>(null); 116authorizationFilterContext.HttpContext.Features.Set<IFormFeature>( 117new FormFeature(authorizationFilterContext.HttpContext.Request));
Filters\RequestSizeLimitFilterTest.cs (4)
24authorizationFilterContext.HttpContext.Features.Set<IHttpMaxRequestBodySizeFeature>(httpMaxRequestBodySize); 45authorizationFilterContext.HttpContext.Features.Set<IHttpMaxRequestBodySizeFeature>(httpMaxRequestBodySize); 89authorizationFilterContext.HttpContext.Features.Set<IHttpMaxRequestBodySizeFeature>(httpMaxRequestBodySize); 111authorizationFilterContext.HttpContext.Features.Set<IHttpMaxRequestBodySizeFeature>(httpMaxRequestBodySize);
Filters\ResponseCacheFilterExecutorTest.cs (14)
29Assert.Equal("no-store", context.HttpContext.Response.Headers["Cache-control"]); 188Assert.Equal(output, context.HttpContext.Response.Headers["Cache-control"]); 245Assert.Equal(output, context.HttpContext.Response.Headers["Cache-control"]); 325Assert.Equal(varyOutput, context.HttpContext.Response.Headers["Vary"]); 326Assert.Equal(cacheControlOutput, context.HttpContext.Response.Headers["Cache-control"]); 402context.HttpContext.Features.Set<IResponseCachingFeature>(new ResponseCachingFeature()); 408Assert.Equal(varyOutput, context.HttpContext.Features.Get<IResponseCachingFeature>().VaryByQueryKeys); 409Assert.Equal(cacheControlOutput, context.HttpContext.Response.Headers.CacheControl); 450Assert.Equal("no-store,no-cache", context.HttpContext.Response.Headers["Cache-control"]); 451Assert.Equal("no-cache", context.HttpContext.Response.Headers["Pragma"]); 470Assert.Equal("public,max-age=20", context.HttpContext.Response.Headers["Cache-control"]); 490Assert.Equal("private,max-age=10", context.HttpContext.Response.Headers["Cache-control"]); 510Assert.Equal("public,max-age=10", context.HttpContext.Response.Headers["Cache-control"]); 530Assert.Equal("Test", context.HttpContext.Response.Headers["Vary"]);
Formatters\JsonOutputFormatterTestBase.cs (4)
41actionContext.HttpContext, 92actionContext.HttpContext, 124actionContext.HttpContext, 185actionContext.HttpContext,
Formatters\SystemTextJsonOutputFormatterTest.cs (7)
46actionContext.HttpContext, 74actionContext.HttpContext, 101actionContext.HttpContext, 126actionContext.HttpContext.RequestAborted = cts.Token; 130actionContext.HttpContext, 192actionContext.HttpContext, 232actionContext.HttpContext,
HttpOkResultTest.cs (1)
39Assert.Equal(StatusCodes.Status200OK, context.HttpContext.Response.StatusCode);
Infrastructure\ControllerActionInvokerTest.cs (1)
1961context.HttpContext.Items["Result"] = Value;
Infrastructure\JsonResultExecutorTestBase.cs (32)
37var written = GetWrittenBytes(context.HttpContext); 39Assert.Equal("application/json; charset=utf-8", context.HttpContext.Response.ContentType); 58var written = GetWrittenBytes(context.HttpContext); 60Assert.Equal("text/json", context.HttpContext.Response.ContentType); 70context.HttpContext.Response.ContentType = "text/json; charset=utf-8"; 82var written = GetWrittenBytes(context.HttpContext); 84Assert.Equal("text/json; charset=utf-16", context.HttpContext.Response.ContentType); 94context.HttpContext.Response.ContentType = "text/json; charset=utf-16"; 102var written = GetWrittenBytes(context.HttpContext); 104Assert.Equal("text/json; charset=utf-16", context.HttpContext.Response.ContentType); 126var written = GetWrittenBytes(context.HttpContext); 128Assert.Equal("text/json; charset=us-ascii", context.HttpContext.Response.ContentType); 139context.HttpContext.Response.ContentType = expectedContentType; 148var written = GetWrittenBytes(context.HttpContext); 150Assert.Equal(expectedContentType, context.HttpContext.Response.ContentType); 164context.HttpContext.Response.ContentType = responseContentType; 173var written = GetWrittenBytes(context.HttpContext); 175Assert.Equal(expectedContentType, context.HttpContext.Response.ContentType); 197var written = GetWrittenBytes(context.HttpContext); 199Assert.Equal("application/json; charset=utf-8", context.HttpContext.Response.ContentType); 228var written = GetWrittenBytes(context.HttpContext); 280context.HttpContext.Response.Body = stream.Object; 323var written = GetWrittenBytes(context.HttpContext); 341var written = GetWrittenBytes(context.HttpContext); 359var written = GetWrittenBytes(context.HttpContext); 368context.HttpContext.RequestAborted = cts.Token; 377var written = GetWrittenBytes(context.HttpContext); 399context.HttpContext.RequestAborted = cts.Token; 411var written = GetWrittenBytes(context.HttpContext); 433context.HttpContext.RequestAborted = cts.Token; 453context.HttpContext.RequestAborted = cts.Token; 461var written = GetWrittenBytes(context.HttpContext);
Infrastructure\ObjectResultExecutorTest.cs (6)
276Assert.Equal(StatusCodes.Status406NotAcceptable, actionContext.HttpContext.Response.StatusCode); 301actionContext.HttpContext.Response.Headers.ContentType); 389actionContext.HttpContext.Request.Headers.Accept = acceptHeader; 395Assert.Equal(expectedContentType, actionContext.HttpContext.Response.Headers.ContentType); 426actionContext.HttpContext.Request.Headers.Accept = acceptHeader; 432var responseContentType = actionContext.HttpContext.Response.Headers.ContentType;
ModelBinding\FormFileValueProviderFactoryTest.cs (1)
48var files = (FormFileCollection)context.ActionContext.HttpContext.Request.Form.Files;
ObjectResultTests.cs (3)
59Assert.Equal(404, actionContext.HttpContext.Response.StatusCode); 122Assert.Equal(StatusCodes.Status413RequestEntityTooLarge, actionContext.HttpContext.Response.StatusCode); 153Assert.Equal(StatusCodes.Status400BadRequest, actionContext.HttpContext.Response.StatusCode);
ResponseCacheAttributeTest.cs (5)
213context.HttpContext.Features.Set<IResponseCachingFeature>(new ResponseCachingFeature()); 219var response = context.HttpContext.Response; 227Assert.Equal(varyByQueryKeys, context.HttpContext.Features.Get<IResponseCachingFeature>().VaryByQueryKeys); 277Assert.True(context.HttpContext.Response.Headers.TryGetValue("Cache-Control", out values)); 296Assert.True(context.HttpContext.Response.Headers.TryGetValue("Cache-Control", out values));
Routing\EndpointRoutingUrlHelperTest.cs (3)
55urlHelper.ActionContext.HttpContext.SetEndpoint(endpoint1); 56urlHelper.ActionContext.HttpContext.Request.RouteValues = new RouteValueDictionary 140var httpContext = actionContext.HttpContext;
Routing\UrlHelperTestBase.cs (5)
921Assert.Same(urlHelper, actionContext.HttpContext.Items[typeof(IUrlHelper)] as IUrlHelper); 944Assert.Same(urlHelper, actionContext.HttpContext.Items[typeof(IUrlHelper)] as IUrlHelper); 968urlHelper.ActionContext.HttpContext.Features.Set<IRouteValuesFeature>(new RouteValuesFeature 1007urlHelper.ActionContext.HttpContext.Features.Set<IRouteValuesFeature>(new RouteValuesFeature 1047urlHelper.ActionContext.HttpContext.Features.Set<IRouteValuesFeature>(new RouteValuesFeature
Microsoft.AspNetCore.Mvc.Cors (5)
CorsAuthorizationFilter.cs (3)
74var httpContext = context.HttpContext; 86var result = _corsService.EvaluatePolicy(context.HttpContext, policy); 87_corsService.ApplyResult(result, context.HttpContext.Response);
DisableCorsAuthorizationFilter.cs (2)
27context.HttpContext.Request.Headers[CorsConstants.AccessControlRequestMethod]; 29context.HttpContext.Request.Method,
Microsoft.AspNetCore.Mvc.Cors.Test (7)
CorsAuthorizationFilterTest.cs (7)
33authorizationContext.HttpContext.Request.Method = preflightRequestMethod; 40var response = authorizationContext.HttpContext.Response; 69Assert.Equal(204, authorizationContext.HttpContext.Response.StatusCode); 70Assert.Empty(authorizationContext.HttpContext.Response.Headers); 90var response = authorizationContext.HttpContext.Response; 112Assert.Equal(200, authorizationContext.HttpContext.Response.StatusCode); 113Assert.Empty(authorizationContext.HttpContext.Response.Headers);
Microsoft.AspNetCore.Mvc.DataAnnotations (2)
DataAnnotationsModelValidator.cs (1)
76serviceProvider: validationContext.ActionContext?.HttpContext?.RequestServices,
ValidatableObjectAdapter.cs (1)
35serviceProvider: context.ActionContext?.HttpContext?.RequestServices,
Microsoft.AspNetCore.Mvc.IntegrationTests (56)
BindingSourceMetadataProviderIntegrationTest.cs (1)
43var token = testContext.HttpContext.RequestAborted;
BindPropertyIntegrationTest.cs (1)
230HttpContext = testContext.HttpContext,
BodyValidationIntegrationTests.cs (9)
379var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 420var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 456var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 562var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 627var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 672var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 720var httpContext = testContext.HttpContext; 827var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 873var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices);
CancellationTokenModelBinderIntegrationTest.cs (3)
47testContext.HttpContext.Abort(); 83testContext.HttpContext.Abort(); 121testContext.HttpContext.Abort();
ComplexRecordIntegrationTest.cs (1)
4253context.HttpContext.RequestServices);
ComplexTypeIntegrationTestBase.cs (1)
3752context.HttpContext.RequestServices);
DictionaryModelBinderIntegrationTest.cs (9)
551var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 589var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 624var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 659var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 744var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 948var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 982var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 1021var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 1060var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices);
ExcludeBindingMetadataProviderIntegrationTest.cs (1)
95var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices);
HeaderModelBinderIntegrationTest.cs (8)
43var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 82var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 124var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 170var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 217var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 277var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 280var httpContext = testContext.HttpContext; 331var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices);
KeyValuePairModelBinderIntegrationTest.cs (2)
112var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 199var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices);
ModelBindingTestContext.cs (1)
16return (T)HttpContext.RequestServices.GetService(typeof(T));
ModelBindingTestHelper.cs (1)
64return GetParameterBinder(testContext.HttpContext.RequestServices);
ParameterBinderExtensions.cs (3)
21var optionsAccessor = context.HttpContext.RequestServices.GetService<IOptions<MvcOptions>>(); 23var modelMetadataProvider = context.HttpContext.RequestServices.GetService<IModelMetadataProvider>(); 65context.HttpContext.RequestServices);
ServicesModelBinderIntegrationTest.cs (2)
356var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 394var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices);
SimpleTypeModelBinderIntegrationTest.cs (2)
432var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 535var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices);
TryValidateModelIntegrationTest.cs (1)
213var options = actionContext.HttpContext.RequestServices.GetRequiredService<IOptions<MvcOptions>>();
ValidationIntegrationTests.cs (5)
1745var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 1796var httpContext = testContext.HttpContext; 1840var httpContext = testContext.HttpContext; 1885var httpContext = testContext.HttpContext; 1932var httpContext = testContext.HttpContext;
ValidationWithRecordIntegrationTests.cs (5)
1548var parameterBinder = ModelBindingTestHelper.GetParameterBinder(testContext.HttpContext.RequestServices); 1599var httpContext = testContext.HttpContext; 1643var httpContext = testContext.HttpContext; 1688var httpContext = testContext.HttpContext; 1735var httpContext = testContext.HttpContext;
Microsoft.AspNetCore.Mvc.NewtonsoftJson (4)
NewtonsoftJsonResultExecutor.cs (4)
75var response = context.HttpContext.Response; 110value = await reader(value, context.HttpContext.RequestAborted); 112catch (OperationCanceledException) when (context.HttpContext.RequestAborted.IsCancellationRequested) { } 113if (context.HttpContext.RequestAborted.IsCancellationRequested)
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (49)
JsonResultTest.cs (2)
34var written = GetWrittenBytes(context.HttpContext); 36Assert.Equal("application/json; charset=utf-8", context.HttpContext.Response.ContentType);
NewtonsoftJsonOutputFormatterTest.cs (9)
444actionContext.HttpContext.RequestAborted = cts.Token; 445actionContext.HttpContext.RequestServices = new ServiceCollection().AddLogging().BuildServiceProvider(); 449actionContext.HttpContext, 489actionContext.HttpContext.RequestAborted = cts.Token; 490actionContext.HttpContext.RequestServices = new ServiceCollection().AddLogging().BuildServiceProvider(); 494actionContext.HttpContext, 523actionContext.HttpContext.RequestAborted = cts.Token; 524actionContext.HttpContext.RequestServices = new ServiceCollection().AddLogging().BuildServiceProvider(); 528actionContext.HttpContext,
NewtonsoftJsonResultExecutorTest.cs (2)
39context.HttpContext.RequestAborted = cts.Token; 48var written = GetWrittenBytes(context.HttpContext);
src\Mvc\Mvc.Core\test\Formatters\JsonOutputFormatterTestBase.cs (4)
41actionContext.HttpContext, 92actionContext.HttpContext, 124actionContext.HttpContext, 185actionContext.HttpContext,
src\Mvc\Mvc.Core\test\Infrastructure\JsonResultExecutorTestBase.cs (32)
37var written = GetWrittenBytes(context.HttpContext); 39Assert.Equal("application/json; charset=utf-8", context.HttpContext.Response.ContentType); 58var written = GetWrittenBytes(context.HttpContext); 60Assert.Equal("text/json", context.HttpContext.Response.ContentType); 70context.HttpContext.Response.ContentType = "text/json; charset=utf-8"; 82var written = GetWrittenBytes(context.HttpContext); 84Assert.Equal("text/json; charset=utf-16", context.HttpContext.Response.ContentType); 94context.HttpContext.Response.ContentType = "text/json; charset=utf-16"; 102var written = GetWrittenBytes(context.HttpContext); 104Assert.Equal("text/json; charset=utf-16", context.HttpContext.Response.ContentType); 126var written = GetWrittenBytes(context.HttpContext); 128Assert.Equal("text/json; charset=us-ascii", context.HttpContext.Response.ContentType); 139context.HttpContext.Response.ContentType = expectedContentType; 148var written = GetWrittenBytes(context.HttpContext); 150Assert.Equal(expectedContentType, context.HttpContext.Response.ContentType); 164context.HttpContext.Response.ContentType = responseContentType; 173var written = GetWrittenBytes(context.HttpContext); 175Assert.Equal(expectedContentType, context.HttpContext.Response.ContentType); 197var written = GetWrittenBytes(context.HttpContext); 199Assert.Equal("application/json; charset=utf-8", context.HttpContext.Response.ContentType); 228var written = GetWrittenBytes(context.HttpContext); 280context.HttpContext.Response.Body = stream.Object; 323var written = GetWrittenBytes(context.HttpContext); 341var written = GetWrittenBytes(context.HttpContext); 359var written = GetWrittenBytes(context.HttpContext); 368context.HttpContext.RequestAborted = cts.Token; 377var written = GetWrittenBytes(context.HttpContext); 399context.HttpContext.RequestAborted = cts.Token; 411var written = GetWrittenBytes(context.HttpContext); 433context.HttpContext.RequestAborted = cts.Token; 453context.HttpContext.RequestAborted = cts.Token; 461var written = GetWrittenBytes(context.HttpContext);
Microsoft.AspNetCore.Mvc.Razor (18)
DefaultTagHelperFactory.cs (1)
75var serviceProvider = context.HttpContext.RequestServices;
Infrastructure\DefaultTagHelperActivator.cs (1)
21return Cache<TTagHelper>.Create(context.HttpContext.RequestServices);
MvcRazorDiagnosticListenerExtensions.cs (2)
37viewContext.HttpContext 67viewContext.HttpContext
RazorPage.cs (1)
23public HttpContext Context => ViewContext?.HttpContext!;
RazorPageBase.cs (7)
134public virtual ClaimsPrincipal User => ViewContext.HttpContext.User; 150var services = ViewContext.HttpContext.RequestServices; 164var services = ViewContext.HttpContext.RequestServices; 355var services = viewContext.HttpContext.RequestServices; 701await ViewContext.HttpContext.Response.Body.FlushAsync(); 716var antiforgery = viewContext.HttpContext.RequestServices.GetRequiredService<IAntiforgery>(); 717antiforgery.SetCookieTokenAndHeader(viewContext.HttpContext);
RazorPagePropertyActivator.cs (2)
85var serviceProvider = context.HttpContext.RequestServices; 126var serviceProvider = context.HttpContext.RequestServices;
RazorView.cs (1)
84_bufferScope = context.HttpContext.RequestServices.GetRequiredService<IViewBufferScope>();
ServiceBasedTagHelperActivator.cs (1)
21return context.HttpContext.RequestServices.GetRequiredService<TTagHelper>();
TagHelpers\TagHelperComponentTagHelper.cs (1)
61var serviceProvider = ViewContext.HttpContext.RequestServices;
TagHelpers\UrlResolutionTagHelper.cs (1)
340return ViewContext.HttpContext.GetEndpoint()?.Metadata.GetMetadata<ResourceAssetCollection>();
Microsoft.AspNetCore.Mvc.Razor.Test (2)
TagHelpers\TagHelperComponentPropertyActivatorTest.cs (1)
57var viewContext = Mock.Of<ViewContext>(vc => vc.HttpContext == httpContext);
TagHelpers\TagHelperComponentTagHelperTest.cs (1)
395var viewContext = Mock.Of<ViewContext>(vc => vc.HttpContext == httpContext);
Microsoft.AspNetCore.Mvc.RazorPages (15)
ApplicationModels\DefaultPageApplicationModelPartsProvider.cs (1)
25_supportsNonGetRequests = context => !HttpMethods.IsGet(context.HttpContext.Request.Method);
Filters\PageSaveTempDataPropertyFilter.cs (1)
23var tempData = _tempDataFactory.GetTempData(context.HttpContext);
Filters\PageViewDataAttributeFilter.cs (1)
27context.HttpContext.Features.Set<IViewDataValuesProviderFeature>(this);
Infrastructure\DefaultPageHandlerMethodSelector.cs (3)
88var httpMethod = context.HttpContext.Request.Method; 155if (context.HttpContext.Request.Query.TryGetValue(Handler, out var queryValues)) 166return HttpMethods.IsHead(context.HttpContext.Request.Method) ? HttpMethods.Get : null;
Infrastructure\DefaultPageModelActivatorProvider.cs (1)
33return (context) => factory(context.HttpContext.RequestServices, Array.Empty<object>());
Infrastructure\HandleOptionsRequestsPageFilter.cs (1)
41HttpMethods.IsOptions(context.HttpContext.Request.Method))
Infrastructure\PageActionInvoker.cs (2)
114_tempDataFactory.GetTempData(_pageContext.HttpContext), 153_tempDataFactory.GetTempData(_pageContext.HttpContext),
Infrastructure\PageResultExecutor.cs (1)
99var viewDataValuesProvider = pageContext.HttpContext.Features.Get<IViewDataValuesProviderFeature>();
Infrastructure\ServiceBasedPageModelActivatorProvider.cs (1)
29return context.HttpContext.RequestServices.GetRequiredService(modelType);
PageBase.cs (1)
42public HttpContext HttpContext => PageContext?.HttpContext!;
PageModel.cs (1)
61public HttpContext HttpContext => PageContext.HttpContext;
PageResult.cs (1)
60var executor = context.HttpContext.RequestServices.GetRequiredService<PageResultExecutor>();
Microsoft.AspNetCore.Mvc.RazorPages.Test (11)
Infrastructure\DefaultPageFactoryProviderTest.cs (4)
229HttpContext = pageContext.HttpContext, 268HttpContext = pageContext.HttpContext, 311HttpContext = pageContext.HttpContext, 349HttpContext = pageContext.HttpContext,
Infrastructure\DisallowOptionsRequestsPageFilterTest.cs (5)
47context.HttpContext.Request.Method = "PUT"; 63context.HttpContext.Request.Method = "DELETE"; 80context.HttpContext.Request.Method = "Options"; 98context.HttpContext.Request.Method = "Options"; 114context.HttpContext.Request.Method = "Options";
Infrastructure\PageActionInvokerProviderTest.cs (2)
141Assert.Same(context.ActionContext.HttpContext, pageContext.HttpContext);
Microsoft.AspNetCore.Mvc.TagHelpers (16)
Cache\CacheTagKey.cs (1)
81var httpContext = tagHelper.ViewContext.HttpContext;
ComponentTagHelper.cs (2)
96var requestServices = ViewContext.HttpContext.RequestServices; 100var result = await componentPrerenderer.PrerenderComponentAsync(ViewContext.HttpContext, ComponentType, renderMode, parameters);
ImageTagHelper.cs (2)
136FileVersionProvider = ViewContext.HttpContext.RequestServices.GetRequiredService<IFileVersionProvider>(); 144var pathBase = ViewContext.HttpContext.Request.PathBase;
LinkTagHelper.cs (3)
477ViewContext.HttpContext.Request.PathBase); 485FileVersionProvider = ViewContext.HttpContext.RequestServices.GetRequiredService<IFileVersionProvider>(); 536var pathBase = ViewContext.HttpContext.Request.PathBase;
PersistComponentStateTagHelper.cs (2)
46var componentPrerenderer = ViewContext.HttpContext.RequestServices.GetRequiredService<IComponentPrerenderer>(); 55var content = await componentPrerenderer.PrerenderPersistedStateAsync(ViewContext.HttpContext, serializationMode);
ResourceCollectionUtilities.cs (2)
14var pathBase = viewContext.HttpContext.Request.PathBase; 15var assetCollection = viewContext.HttpContext.GetEndpoint()?.Metadata.GetMetadata<ResourceAssetCollection>();
ScriptTagHelper.cs (4)
247var importMap = ImportMap ?? ViewContext.HttpContext.GetEndpoint()?.Metadata.GetMetadata<ImportMapDefinition>(); 416var pathBase = ViewContext.HttpContext.Request.PathBase; 465ViewContext.HttpContext.Request.PathBase); 473FileVersionProvider = ViewContext.HttpContext.RequestServices.GetRequiredService<IFileVersionProvider>();
Microsoft.AspNetCore.Mvc.TagHelpers.Test (44)
CacheTagHelperTest.cs (4)
105cacheTagHelper1.ViewContext.HttpContext.Request.QueryString = new QueryString( 127cacheTagHelper2.ViewContext.HttpContext.Request.QueryString = new QueryString( 156cacheTagHelper1.ViewContext.HttpContext.Request.Headers["Cookie"] = "cookie1=value1;cookie2=value2"; 178cacheTagHelper2.ViewContext.HttpContext.Request.Headers["Cookie"] = "cookie1=value1;cookie2=not-value2";
CacheTagKeyTest.cs (7)
211cacheTagHelper.ViewContext.HttpContext.Request.Headers["Cookie"] = 237var headers = cacheTagHelper.ViewContext.HttpContext.Request.Headers; 265cacheTagHelper.ViewContext.HttpContext.Request.QueryString = 359cacheTagHelper.ViewContext.HttpContext.User = new ClaimsPrincipal(identity); 404cacheTagHelper.ViewContext.HttpContext.Request.Headers["Content-Type"] = "text/html"; 406cacheTagHelper.ViewContext.HttpContext.User = new ClaimsPrincipal(identity); 431cacheTagHelper.ViewContext.HttpContext.Request.Headers["Content-Type"] = "text/html";
ComponentTagHelperTest.cs (1)
39var prerenderer = viewContext.HttpContext.RequestServices.GetRequiredService<IComponentPrerenderer>();
DistributedCacheTagHelperTest.cs (4)
148cacheTagHelper1.ViewContext.HttpContext.Request.QueryString = new QueryString( 173cacheTagHelper2.ViewContext.HttpContext.Request.QueryString = new QueryString( 208cacheTagHelper1.ViewContext.HttpContext.Request.Headers["Cookie"] = "cookie1=value1;cookie2=value2"; 232cacheTagHelper2.ViewContext.HttpContext.Request.Headers["Cookie"] = "cookie1=value1;cookie2=not-value2";
FormTagHelperTest.cs (1)
154viewContext.HttpContext.Request.Path = "/home/index";
ImageTagHelperTest.cs (3)
197helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 200helper.ViewContext.HttpContext.Request.PathBase = new PathString(pathBase); 296actionContext.HttpContext.Request.PathBase = new Http.PathString(requestPathBase);
LinkTagHelperTest.cs (6)
750helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 791helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 792helper.ViewContext.HttpContext.Request.PathBase = "/approot"; 925helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 1080helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 1127actionContext.HttpContext.Request.PathBase = new PathString(requestPathBase);
PersistComponentStateTagHelperTest.cs (8)
88var manager = tagHelper.ViewContext.HttpContext.RequestServices.GetRequiredService<ComponentStatePersistenceManager>(); 114EndpointHtmlRenderer.UpdateSaveStateRenderMode(tagHelper.ViewContext.HttpContext, RenderMode.InteractiveWebAssembly); 118var manager = tagHelper.ViewContext.HttpContext.RequestServices.GetRequiredService<ComponentStatePersistenceManager>(); 147var manager = tagHelper.ViewContext.HttpContext.RequestServices.GetRequiredService<ComponentStatePersistenceManager>(); 196EndpointHtmlRenderer.UpdateSaveStateRenderMode(tagHelper.ViewContext.HttpContext, Components.Web.RenderMode.InteractiveServer); 200var manager = tagHelper.ViewContext.HttpContext.RequestServices.GetRequiredService<ComponentStatePersistenceManager>(); 228EndpointHtmlRenderer.UpdateSaveStateRenderMode(tagHelper.ViewContext.HttpContext, Components.Web.RenderMode.InteractiveServer); 229EndpointHtmlRenderer.UpdateSaveStateRenderMode(tagHelper.ViewContext.HttpContext, Components.Web.RenderMode.InteractiveWebAssembly);
ScriptTagHelperTest.cs (10)
659helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 696helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 697helper.ViewContext.HttpContext.Request.PathBase = "/approot"; 742helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 786helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint(importMap)); 882helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 1012helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 1051helper.ViewContext.HttpContext.SetEndpoint(CreateEndpoint()); 1052helper.ViewContext.HttpContext.Request.PathBase = "/approot"; 1108actionContext.HttpContext.Request.PathBase = new PathString(requestPathBase);
Microsoft.AspNetCore.Mvc.ViewFeatures (50)
DefaultDisplayTemplates.cs (2)
92var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices; 208var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices;
DefaultEditorTemplates.cs (2)
74var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices; 250var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices;
DefaultHtmlGenerator.cs (2)
183return _antiforgery.GetHtml(viewContext.HttpContext); 281var request = viewContext.HttpContext.Request;
Filters\AntiforgeryMiddlewareAuthorizationFilter.cs (2)
19if (context.HttpContext.Items.ContainsKey(AntiforgeryMiddlewareWithEndpointInvokedKey)) 21var antiforgeryValidationFeature = context.HttpContext.Features.Get<IAntiforgeryValidationFeature>();
Filters\AutoValidateAntiforgeryTokenAuthorizationFilter.cs (1)
22var method = context.HttpContext.Request.Method;
Filters\ControllerSaveTempDataPropertyFilter.cs (1)
23var tempData = _tempDataFactory.GetTempData(context.HttpContext);
Filters\ControllerViewDataAttributeFilter.cs (1)
26context.HttpContext.Features.Set<IViewDataValuesProviderFeature>(this);
Filters\SaveTempDataFilter.cs (10)
32if (!context.HttpContext.Items.ContainsKey(SaveTempDataFilterContextKey)) 39context.HttpContext.Items.Add(SaveTempDataFilterContextKey, tempDataContext); 42if (!context.HttpContext.Response.HasStarted) 44context.HttpContext.Response.OnStarting( 46state: context.HttpContext); 84if (!context.HttpContext.Response.HasStarted && context.Exception != null) 86var saveTempDataContext = GetTempDataContext(context.HttpContext); 105if (!context.HttpContext.Response.HasStarted) 107SaveTempData(context.Result, _factory, context.Filters, context.HttpContext); 109var saveTempDataContext = GetTempDataContext(context.HttpContext);
Filters\ValidateAntiforgeryTokenAuthorizationFilter.cs (1)
37await _antiforgery.ValidateRequestAsync(context.HttpContext);
NameAndIdProvider.cs (2)
43var items = viewContext.HttpContext.Items; 142var items = viewContext.HttpContext.Items;
PageRemoteAttribute.cs (1)
43var services = context.ActionContext.HttpContext.RequestServices;
PartialViewResult.cs (1)
64var services = context.HttpContext.RequestServices;
RemoteAttribute.cs (1)
111var services = context.ActionContext.HttpContext.RequestServices;
RemoteAttributeBase.cs (1)
179var services = context.ActionContext.HttpContext.RequestServices;
Rendering\HtmlHelperComponentExtensions.cs (1)
62var httpContext = htmlHelper.ViewContext.HttpContext;
SkipStatusCodePagesAttribute.cs (1)
26var statusCodeFeature = context.HttpContext.Features.Get<IStatusCodePagesFeature>();
TemplateRenderer.cs (1)
240var newHelper = viewContext.HttpContext.RequestServices.GetRequiredService<IHtmlHelper>();
ViewComponent.cs (6)
34public HttpContext HttpContext => ViewContext?.HttpContext!; 39public HttpRequest Request => ViewContext?.HttpContext?.Request!; 44public IPrincipal User => ViewContext?.HttpContext?.User!; 49public ClaimsPrincipal UserClaimsPrincipal => ViewContext?.HttpContext?.User!; 87var services = ViewComponentContext.ViewContext?.HttpContext?.RequestServices; 151var services = ViewComponentContext.ViewContext?.HttpContext?.RequestServices;
ViewComponentResult.cs (1)
63var services = context.HttpContext.RequestServices;
ViewComponentResultExecutor.cs (4)
72var response = context.HttpContext.Response; 83tempData = _tempDataDictionaryFactory.GetTempData(context.HttpContext); 113var viewComponentHelper = context.HttpContext.RequestServices.GetRequiredService<IViewComponentHelper>(); 138var viewDataValuesProvider = viewContext.HttpContext.Features.Get<IViewDataValuesProviderFeature>();
ViewComponents\DefaultViewComponentActivator.cs (1)
49context.ViewContext.HttpContext.RequestServices,
ViewComponents\ServiceBasedViewComponentActivator.cs (1)
21return context.ViewContext.HttpContext.RequestServices.GetRequiredService(viewComponentType);
ViewComponents\ViewViewComponentResult.cs (2)
113_diagnosticListener = viewContext.HttpContext.RequestServices.GetRequiredService<DiagnosticListener>(); 131return context.ViewContext.HttpContext.RequestServices.GetRequiredService<ICompositeViewEngine>();
ViewExecutor.cs (3)
154tempData = TempDataFactory.GetTempData(actionContext.HttpContext); 187var response = viewContext.HttpContext.Response; 235var viewDataValuesProvider = viewContext.HttpContext.Features.Get<IViewDataValuesProviderFeature>();
ViewResult.cs (1)
64var executor = context.HttpContext.RequestServices.GetService<IActionResultExecutor<ViewResult>>();
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (57)
ControllerUnitTestabilityTests.cs (2)
570Assert.Null(controller.ControllerContext.HttpContext); 585Assert.Equal(controllerContext.HttpContext, controller.HttpContext);
Filters\AutoValidateAntiforgeryTokenAuthorizationFilterTest.cs (3)
32actionContext.HttpContext.Request.Method = httpMethod; 60actionContext.HttpContext.Request.Method = httpMethod; 84actionContext.HttpContext.Request.Method = "POST";
Filters\SaveTempDataFilterTest.cs (2)
385return context.HttpContext.Response.WriteAsync($"Hello from {nameof(TestActionResult)}"); 393return context.HttpContext.Response.WriteAsync($"Hello from {nameof(TestKeepTempDataActionResult)}");
Filters\ValidateAntiforgeryTokenAuthorizationFilterTest.cs (3)
36actionContext.HttpContext.Request.Method = httpMethod; 60actionContext.HttpContext.Request.Method = "POST"; 88actionContext.HttpContext.Request.Method = "POST";
PartialViewResultExecutorTest.cs (2)
301Assert.Equal("application/x-my-content-type", context.HttpContext.Response.ContentType); 330Assert.Equal(404, context.HttpContext.Response.StatusCode);
RemoteAttributeBaseTest.cs (4)
223var options = context.ActionContext.HttpContext.RequestServices 270var options = context.ActionContext.HttpContext.RequestServices 315var options = context.ActionContext.HttpContext.RequestServices 407var options = context.ActionContext.HttpContext.RequestServices
RemoteAttributeTest.cs (1)
419actionContext.HttpContext.RequestServices = serviceProvider;
Rendering\HtmlHelperFormTest.cs (16)
134Assert.NotNull(htmlHelper.ViewContext.HttpContext); 135var request = htmlHelper.ViewContext.HttpContext.Request; 184Assert.NotNull(htmlHelper.ViewContext.HttpContext); 185var request = htmlHelper.ViewContext.HttpContext.Request; 341viewContext.HttpContext.RequestServices = serviceProvider.Object; 388viewContext.HttpContext.RequestServices = serviceProvider.Object; 426viewContext.HttpContext.RequestServices = serviceProvider.Object; 465viewContext.HttpContext.RequestServices = serviceProvider.Object; 503viewContext.HttpContext.RequestServices = serviceProvider.Object; 543viewContext.HttpContext.RequestServices = serviceProvider.Object; 582viewContext.HttpContext.RequestServices = serviceProvider.Object; 622viewContext.HttpContext.RequestServices = serviceProvider.Object; 659viewContext.HttpContext.RequestServices = serviceProvider.Object; 702viewContext.HttpContext.RequestServices = serviceProvider.Object; 744viewContext.HttpContext.RequestServices = serviceProvider.Object; 788viewContext.HttpContext.RequestServices = serviceProvider.Object;
Rendering\ViewContextTests.cs (2)
69Assert.Same(originalContext.HttpContext, context.HttpContext);
SkipStatusCodePagesAttributeTest.cs (1)
22resourceExecutingContext.HttpContext.Features.Set<IStatusCodePagesFeature>(statusCodePagesFeature);
ViewComponentResultTest.cs (16)
152var services = CreateServices(diagnosticListener: null, context: actionContext.HttpContext); 194var body = ReadBody(actionContext.HttpContext.Response); 225var body = ReadBody(actionContext.HttpContext.Response); 256var body = ReadBody(actionContext.HttpContext.Response); 289var body = ReadBody(actionContext.HttpContext.Response); 328var body = ReadBody(actionContext.HttpContext.Response); 359var body = ReadBody(actionContext.HttpContext.Response); 390var body = ReadBody(actionContext.HttpContext.Response); 432var body = ReadBody(actionContext.HttpContext.Response); 474var body = ReadBody(actionContext.HttpContext.Response); 506Assert.Equal(404, actionContext.HttpContext.Response.StatusCode); 568var resultContentType = actionContext.HttpContext.Response.ContentType; 595actionContext.HttpContext.Response.ContentType = "application/x-will-be-overridden"; 609Assert.Equal(expectedContentType, actionContext.HttpContext.Response.ContentType); 633actionContext.HttpContext.Response.ContentType = expectedContentType; 646Assert.Equal(expectedContentType, actionContext.HttpContext.Response.ContentType);
ViewComponents\HtmlContentViewComponentResultTest.cs (1)
46new TempDataDictionary(actionContext.HttpContext, Mock.Of<ITempDataProvider>()),
ViewComponents\ViewViewComponentResultTest.cs (2)
365viewComponentContext.ViewContext.HttpContext.RequestServices = serviceProvider.Object; 439viewComponentContext.ViewContext.HttpContext.RequestServices = serviceProvider;
ViewResultExecutorTest.cs (2)
296Assert.Equal("application/x-my-content-type", context.HttpContext.Response.ContentType); 320Assert.Equal(404, context.HttpContext.Response.StatusCode);
Mvc.RoutingWebSite (7)
Controllers\ContactController.cs (2)
20return _generator.Generate(Url.RouteUrl("ActionAsMethod", null, Url.ActionContext.HttpContext.Request.Scheme)); 25return _generator.Generate(Url.RouteUrl("ActionAsMethod", null, Url.ActionContext.HttpContext.Request.Scheme));
Controllers\LoginController.cs (2)
20return _generator.Generate(Url.RouteUrl("ActionAsMethod", null, Url.ActionContext.HttpContext.Request.Scheme)); 25return _generator.Generate(Url.RouteUrl("ActionAsMethod", null, Url.ActionContext.HttpContext.Request.Scheme));
src\Mvc\test\WebSites\Common\TestResponseGenerator.cs (3)
27var query = _actionContext.HttpContext.Request.Query; 43actualUrl = _actionContext.HttpContext.Request.Path.Value, 56var services = context.HttpContext.RequestServices;
RazorPagesWebSite (8)
CustomActionResult.cs (2)
12context.HttpContext.Response.StatusCode = 200; 13return context.HttpContext.Response.WriteAsync(nameof(CustomActionResult));
Pages\Filters\TestPageFilter.cs (1)
16context.HttpContext.Response.Headers["PageFilterKey"] = "PageFilterValue";
Pages\Filters\TestPageModelFilter.cs (1)
16context.HttpContext.Response.Headers["PageModelFilterKey"] = "PageModelFilterValue";
Pages\ShortCircuitPageAtAuthFilter.cshtml.cs (2)
29if (ShouldShortCircuit(context.HttpContext, nameof(OnAuthorizationAsync))) 41if (ShouldShortCircuit(context.HttpContext, nameof(OnAuthorization)))
Pages\ShortCircuitPageAtPageFilter.cshtml.cs (2)
36if (ShouldShortCircuit(context.HttpContext, nameof(OnPageHandlerExecutionAsync))) 53if (ShouldShortCircuit(context.HttpContext, nameof(OnPageHandlerExecuting)))
VersioningWebSite (3)
src\Mvc\test\WebSites\Common\TestResponseGenerator.cs (3)
27var query = _actionContext.HttpContext.Request.Query; 43actualUrl = _actionContext.HttpContext.Request.Path.Value, 56var services = context.HttpContext.RequestServices;
XmlFormattersWebSite (2)
Controllers\XmlDataContractApiController.cs (1)
26var mvcOptions = context.HttpContext.RequestServices.GetRequiredService<IOptions<MvcOptions>>();
Controllers\XmlSerializedApiController.cs (1)
26var mvcOptions = context.HttpContext.RequestServices.GetRequiredService<IOptions<MvcOptions>>();