owin

“System.MissingMemberException: The server factory could not be located” starting Microsoft.Owin self-hosted in TeamCity

天涯浪子 提交于 2019-12-12 08:21:47
问题 When Teamcity runs an integration test that starts a self-hosted webapplication, the test fails with the error: System.MissingMemberException: The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener The code throwing this error is: var webApp = WebApp.Start<Startup>("http://*:52203/") The test runs fine when executed withing Visual Studio (using the Resharper test runner). Teamcity is configured to use the JetBrains.BuildServer.NUnitLauncher.exe

Asp .Net Identity 2 - Logging out other sessions (using security stamp) after password update also logs out current session

纵饮孤独 提交于 2019-12-12 08:04:51
问题 I need to immediately invalidate and log out any other logged in sessions when a user changes their password, but allow the active session (who has just updated their password) to remain logged in. To do this, I'm using the UpdateSecurityStampAsync(currentUser.Id); method on the UserManager. All other sessions are successfully logged out, but the active session is also logged out despite the call to SignInAsync after updating the security stamp. The Identity configuration I'm using is as

Simple Injector fails to inject per Web API request registered class during Owin startup

て烟熏妆下的殇ゞ 提交于 2019-12-12 07:48:48
问题 I'm creating an API using Owin, Web API, Entity Framework, ASP.NET Identity. I'm using Simple Injector as my DI framework of choice. During the Owin startup process, I want to seed my database with some sample data. This is handled by a class implementing IDatabaseInitializer , which looks something like this: public class MyDbInitializer : DropCreateDatabaseAlways<MyDataContext> { private readonly IUserManager _userManager; public MyDbInitializer(IUserManager userManager) { _userManager =

WebApp.Start<TStartup> Method Type Parameter

五迷三道 提交于 2019-12-12 07:45:38
问题 In setting up my Windows Service application to self host using Owin based on this article: http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api I used this overload of the WebApp.Start method: WebApp.Start Method (String) Here is my code: //(in startup method) _server = WebApp.Start<Startup>(BaseAddress); public class Startup { // This code configures Web API. The Startup class is specified as a type // parameter in the WebApp.Start method. public void

How to fetch email in web api 2 which is secured by WAAD

让人想犯罪 __ 提交于 2019-12-12 05:44:18
问题 I am using MVC 5 client which is secured by "UseOpenIdConnectAuthentication" and getting all user details in Claims object, this client is calling WAAD secured Web Api by "Bearer" authentication token. I need to fetch username or email in the web api. I tried different options but nothing worked. I am getting null in Identity.Name, other properties I am getting like nameidentifier, objectidentifier, tenanted etc. Please advise. Thanks Below code I am using for access token in Web Client.

How do you setup mixed authorizations for different authentications in .net (web api 2 + owin)

天大地大妈咪最大 提交于 2019-12-12 04:12:43
问题 I am fairly new to .net and I am trying to create a restfull service where you can authenticate via OAuth2 to a service like facebook and also be able to login with a "normal account". The SPA template from VS2013 allowed me to do this quickly and easily and I am very happy with it. Right now I am facing a different problem. I can't seem to find a way to separate access for these different types of logins. For example, I want to allow only users from the oauth authentication method to access

Resolve Autofac dependencies in OWIN Startup class

时光毁灭记忆、已成空白 提交于 2019-12-12 03:58:24
问题 I have a multi-tenant MVC5 webapp, which is using Autofac v3.5.2 and Autofac.Mvc5 v3.3.4. My Autofac DI wiring takes place in a class within my MVC project. For authentication, we are using OWIN OpenId middleware to integrate with Azure B2C. In the OWIN Startup class I need a dependency to set tenantId / clientId using information from the current request. I try to grab the dependency via : DependencyResolver.Current.GetService<...>(); However, this always throws an ObjectDisposedException

OperationContext.Current and HttpContext.Current are null in OWIN hosted Web API 2

谁说我不能喝 提交于 2019-12-12 03:57:06
问题 I am moving some of WCF services to the Web API. OperationContext.Current is usually used in WCF for logging and staging purposes. But i'm seeing HttpContext.Current and OperationContext.Current as null. I have used a framework which uses OperationContext.Current to get the execution context for the current thread. So if i am opting for other ways, i have to add my custom method to the framework, which i am trying to avoid. Questions: What is the workaround that i can adopt? If "adding to

Get OWIN running address inside Startup Configuration method

六眼飞鱼酱① 提交于 2019-12-12 03:25:18
问题 I have a WebApi with OWIN startup class. I want to call a method inside the Configuration method (in order to register the web api) and I need the address of the service (like localhost:12345 ). How could I be able to get it? public class Startup { public void Configuration(IAppBuilder app) { var config = new HttpConfiguration(); ... config.Formatters.Clear(); config.Formatters.Add(new JsonMediaTypeFormatter()); RegisterService(serviceAddress); // <- here ... } } 回答1: I did something like

Why is the Configuration method of the SignalR Startup class invoked twice

大兔子大兔子 提交于 2019-12-12 03:23:56
问题 I am running some initialization code in the Startup class used by SignalR. The code is invoked in the Configuration method (this is in as ASPNET MVC app). The initialization code needs to run exactly once and is placed in the Configuration(IAppBuilder app) method of the Startup class like so: public void Configuration(IAppBuilder app) { //Call some custom pre initialization code ConfigureAuth(app); //Call some custom post initialization code } I noticed that the public void Configuration