Use new HttpContext.Features API.

This commit is contained in:
Chris R 2015-08-31 10:57:21 -07:00
parent 1c986b3bb5
commit 370475b807
3 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Features;
using Microsoft.AspNet.Http.Features.Internal;
using Microsoft.AspNet.Http.Internal;
using Xunit;
@ -16,7 +17,7 @@ namespace MusicStore.Models
var cartId = "cartId_A";
var httpContext = new DefaultHttpContext();
httpContext.SetFeature<IRequestCookiesFeature>(new CookiesFeature("Session", cartId));
httpContext.Features.Set<IRequestCookiesFeature>(new CookiesFeature("Session", cartId));
var cart = new ShoppingCart(new MusicStoreContext());

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Features;
using Microsoft.AspNet.Http.Features.Authentication;
using Microsoft.AspNet.Http.Features.Authentication.Internal;
using Microsoft.AspNet.Http.Internal;
@ -34,7 +35,7 @@ namespace MusicStore.Controllers
// IHttpContextAccessor is required for SignInManager, and UserManager
var context = new DefaultHttpContext();
context.SetFeature<IHttpAuthenticationFeature>(new HttpAuthenticationFeature() { Handler = new TestAuthHandler() });
context.Features.Set<IHttpAuthenticationFeature>(new HttpAuthenticationFeature() { Handler = new TestAuthHandler() });
services.AddInstance<IHttpContextAccessor>(
new HttpContextAccessor()
{

View File

@ -4,11 +4,12 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNet.Antiforgery;
using Microsoft.Data.Entity;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Features;
using Microsoft.AspNet.Http.Features.Internal;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
using Microsoft.Framework.DependencyInjection;
using MusicStore.Models;
using MusicStore.ViewModels;
@ -180,7 +181,7 @@ namespace MusicStore.Controllers
// ServiceProvder initialization
var serviceProviderFeature = new ServiceProvidersFeature();
httpContext.SetFeature<IServiceProvidersFeature>(serviceProviderFeature);
httpContext.Features.Set<IServiceProvidersFeature>(serviceProviderFeature);
// AntiForgery initialization
serviceProviderFeature.RequestServices = _serviceProvider;