owin

Owin Context to use a single instance per request

核能气质少年 提交于 2019-12-10 21:53:07
问题 app.CreatePerOwinContext(DataContext.Create); I have the above line to create a data context this code came with project when i kick a new MVC 5 project. At the same time, i am using autofac to inject single instance per request in my dependency registrar. builder.RegisterType<DataContext>().As<IDbContext>().InstancePerRequest(); What is the best way to use owin and DI container? I have a DataContext class which has a static Method called Create as above and this break when I try to inject a

How am I getting a windows identity in this code?

牧云@^-^@ 提交于 2019-12-10 21:09:35
问题 Related to this problem: Owin Stage Markers I'm using owin and identity framework to init an IIS hosted web app with authentication ... public static void Configure(IAppBuilder app, IKernel kernel) { // ensure that owin creates the required UserManager & sign in manager per owin instance app.CreatePerOwinContext<ApplicationUserManager>((options, owinContext) => ApplicationUserManager.Create(options, owinContext, kernel)); app.CreatePerOwinContext<ApplicationSignInManager>((options,

Multiple cookies issue in OWIN security AuthenticationHandler

老子叫甜甜 提交于 2019-12-10 21:05:28
问题 I am using Facebook Owin Authentication and more or less follow Microsoft sample. I am more or less following the First time user logs in, everything is ok. But if they sign out and try again, it seems like the previous .AspNet.Correlation.Facebook is not removed, but set to empty string. So my next call to api/getexternallogin looks like this in Fiddler: This is when we are generating a correlationId and having multiple cookies at this point is not a show stopper. In the response, I set it

Web Api 2 get controller and action name in OWIN middleware?

那年仲夏 提交于 2019-12-10 20:45:25
问题 How can I retrieve the api controller name and api action name inside a piece of custom OWIN middleware? I can do it inside of a message handler like so: var config = request.GetConfiguration(); var routeData = config.Routes.GetRouteData(request); var controllerContext = new HttpControllerContext(config, routeData, request); request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData; controllerContext.RouteData = routeData; var controllerDescriptor = new DefaultHttpControllerSelector

OWIN Middleware & CallContext

好久不见. 提交于 2019-12-10 19:12:24
问题 I have a few middlewares before the OAuth Middleware and a few after it. app.Use<Middleware1> app.Use<Middleware2> app.UseOAuthBearerTokens(OAuthOptions) app.Use<Middleware3> app.Use<Middleware4> app.Use<Middleware5> If I set something in the CallContext in Middleware1 or in Middleware2, it isn't available in Middleware3 or 4 or in any of the API controllers; whereas, if I set something in the CallContext in Middleware3 or 4, it's available in all the succeeding middlewares and the API

Why is ASP.NET Web Api's Dependency Resolver being disposed?

我们两清 提交于 2019-12-10 18:49:01
问题 I have a custom IDependencyResolver : internal class NinjectResolver : IDependencyResolver { private IKernel _kernel; internal NinjectResolver(params ApplicationModule[] modules) { _kernel = new StandardKernel(modules); } public IDependencyScope BeginScope() { return this; } public object GetService(Type serviceType) { return _kernel.TryGet(serviceType); } public IEnumerable<object> GetServices(Type serviceType) { return _kernel.GetAll(serviceType); } protected void Dispose(bool disposing) {

MVC Anti forgery token error on scaffold

﹥>﹥吖頭↗ 提交于 2019-12-10 18:14:05
问题 I'm recieving the following error: {"A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier' or 'http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider' was not present on the provided ClaimsIdentity. To enable anti-forgery token support with claims-based authentication, please verify that the configured claims provider is providing both of these claims on the ClaimsIdentity instances it generates. If the configured claims provider

OnValidateIdentity session is null - Mvc Owin

大憨熊 提交于 2019-12-10 17:56:11
问题 Currently, I have problems when access Session in OnValidateIdentity - HttpContext.Current.Session is null. What's I wrong . My application as below: - I have 2 project : Mvc vs WebApi - I want user will logout when I changed password -> change security stamp. - I implement as: The Mvc Project will validate SecurityStamp changed when user request. And I'm will get SecurityStamp from other webapi website . This mean My mvc not access directly to database that through out webapi. And I'm must

register new middleware to OWIN pipeline at runtime without restart application

假如想象 提交于 2019-12-10 17:55:34
问题 I have added all available middleware in OWIN Pipeline using Startup class to authenticate user in my project. It is working fine. But how can I add middleware to OWIN Pipeline after Startup at runtime. So that Admin can enter the details of new Authentication Server using UI and register new authentication server on demand without disturbing running application. 回答1: Actually, standard owin pipeline implementation is not designed to be modified during runtime. It has two lifetime phase: init

What is the new Startup.cs file for in Visual Studio 2013 projects?

时光怂恿深爱的人放手 提交于 2019-12-10 17:37:50
问题 I have just installed Visual Studio 2013, created an MVC Web Application project and noticed a new file in the project template called Startup.cs. What is this, how is this different from Global.asax.cs and are there any good best practices on what to use this for? 回答1: Every OWIN application has a startup class where you specify components for the application pipeline. If you start a new Visual Studio project, you'll see pieces of OWIN in it. OWIN is a specification that defines an API for