owin

HttpContext.GetOwinContext().GetUserManager<AppRoleManager>() return null

只谈情不闲聊 提交于 2019-12-09 04:38:44
问题 I've used ASP.NET Identity 2 for creating role but the result of HttpContext.GetOwinContext().GetUserManager<AppRoleManager>() was null. Then I couldn't create the role. How can I solve this problem? public class MVCController : Controller { public MVCController() { } public AppRoleManager RoleManager // returns null ?! { get { return HttpContext.GetOwinContext().GetUserManager<AppRoleManager>(); } } public User CurrentUser { get { string currentUserId = User.Identity.GetUserId(); User

How to override default unhandled exception output in Owin?

佐手、 提交于 2019-12-08 23:42:22
问题 I've written simple server using Owin Self-hosting and WebApi: namespace OwinSelfHostingTest { using System.Threading; using System.Web.Http; using Microsoft.Owin.Hosting; using Owin; public class Startup { public void Configuration(IAppBuilder builder) { var config = new HttpConfiguration(); config.Routes.MapHttpRoute( "Default", "{controller}/{id}", new { id = RouteParameter.Optional } ); builder.UseWebApi(config); } } public class Server { private ManualResetEvent resetEvent = new

Does ASP.NET Core still use OWIN?

≡放荡痞女 提交于 2019-12-08 23:27:44
问题 I noticed when using C# to build an older MVC project, that there is a lot of references to an OWIN library. But when creating a .NET Core web application in VS2015 SP3, seems there's no reference to it. Is this library obsoleted? 回答1: OWIN is not a library, it's a specification. From the docs, OWIN defines a standard interface between .NET web servers and web applications. The "big idea" of OWIN is that you can decouple applications from the servers they run on, if everyone can agree on a

Asp.Net Identity - Updating Claims After Login

杀马特。学长 韩版系。学妹 提交于 2019-12-08 17:43:21
问题 I am using asp.net identity (WebApi 2, MVC 5, not .net core) to add claims to my user's identity when she logs in from our singe page application. This looks like this (I have stripped out the checks for invalid names, locked accounts, etc) public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var userManager = context.OwinContext.GetUserManager<CompWalkUserManager>(); var user = await userManager.FindByNameAsync(context.UserName); var

Share default OWIN tokens in .Net core

蹲街弑〆低调 提交于 2019-12-08 17:40:34
问题 I have Authorization server which built on .NET 4.5.1 and use Microsoft.Owin.Security.OAuth Version=3.0.0 http://prntscr.com/hvwhl4 Tokens protected via machinkey (OAuthAuthorizationServerOptions.AccessTokenFormat is default). I also have many application-consumers(resource servers) on .NET 4.5.1 which validate these tokens http://prntscr.com/hvwwdu http://prntscr.com/hvwiwr. All these applications have the same machinkey in web.config Now I try to build .net core 2.0 application and I need

Hangfire Dashboard Authorization Config Not working

筅森魡賤 提交于 2019-12-08 15:13:24
问题 I've downloaded the nu-get package Hangfire.Dashboard.Authorization I'm trying configure the OWIN based authorization as per the docs as follows but I get intellisense error DashboardOptions.AuthorizationFilters is obsolete please use Authorization property instead I also get intellisense error The type or namespace AuthorizationFilter and ClaimsBasedAuthorizationFilterd not be found using Hangfire.Dashboard; using Hangfire.SqlServer; using Owin; using System; namespace MyApp { public class

Signalr Owin simple example javascript client not being called

断了今生、忘了曾经 提交于 2019-12-08 12:42:07
问题 I have a 5.3.0 version of signalr self hosting that is being upgraded to a newer version of signalr. Using https://github.com/SignalR/SignalR/wiki/Self-host example i have created a simple example, but i can’t get it to work. I can get a connection to the hub on the server and call methods on the hub, but i can’t get the hub to call the javascript client. When looking at it in fiddler I never see a response come back from the hub. Here is the code using System; using Microsoft.AspNet.SignalR;

How to add a custom MVC controller to Identityserver3 owin application

早过忘川 提交于 2019-12-08 10:56:14
问题 I have an owin app which issues OAuth token to different applications. Which is using IdentityServer3 for issuing tokens. My requirement is I need to implement custom MFA for some of the apps before releasing the token. The MFA controller is a custom implementation and have a custom view. I added an MVC controller in my owin app that contains identityserver3 code, and before release the token, to app, I redirected the user to this controller method. My issue is I am not able to read the user

URL Rewrite Module (IIS) not working with OWIN Middleware hosted on IIS

烂漫一生 提交于 2019-12-08 10:17:31
问题 How can i use the URL Rewrite module together with OWIN middleware? Having read http://www.asp.net/aspnet/overview/owin-and-katana/owin-middleware-in-the-iis-integrated-pipeline it says I should be able to use OWIN Middleware in the IIS pipeline using the NuGet package: Microsoft.Owin.Host.SystemWeb Here is the code I am trying to use: Web.config: <system.webServer> <rewrite> <rules> <rule name="pandainserter" patternSyntax="ECMAScript" stopProcessing="true"> <match url=".*test.*" />

Web API 2 + MVC 5 Share Identity Table

 ̄綄美尐妖づ 提交于 2019-12-08 09:12:02
问题 I have a web API and MVC5 sharing the same Identity Table. The Context belonging to the Web API: public partial class CrestfineContext: IdentityDbContext<ApplicationUser> { public CrestfineContext(): base("WelbeckDatabase", throwIfV1Schema: false) { } protected override void OnModelCreating(DbModelBuilder builder) { builder.Conventions.Remove<PluralizingTableNameConvention>(); builder.Entity<IdentityUserClaim>().ToTable("UserClaim").HasKey<Int32>(r => r.Id); builder.Entity<IdentityUserLogin>(