owin

How to use signalr v2 beta in asp.net mvc 4

谁说胖子不能爱 提交于 2019-12-10 17:24:43
问题 Before v2: RouteTable.Routes.MapHubs(); In v2, MapHubs does not exist anymore. The wiki says to add a Startup class and a Configuration method and a call to app.MapHubs(). namespace MyAssembly { public class Startup { public void Configuration(IAppBuilder app) { //Before v2 //RouteTable.Routes.MapHubs(); app.MapHubs(); } } } But the method is never called, no error occurs, and ... no hub are setup. I suppose there is some code to add to global.asax.cs What is the secret ? 回答1: Try defining

Mvc, Authorize bounces authorized users

人盡茶涼 提交于 2019-12-10 15:38:06
问题 I'm trying to make a section of a MVC 5 webpage restricted to users of a certain Active directory group, however the [Authorize] attribute (on controller) blocks logged in users aswell. My Login page code behind looks as follows: public class AccountController: Controller { [AllowAnonymous] public ActionResult Login(string returnUrl) { ViewBag.ReturnUrl = returnUrl; return View(); } // POST: /Account/Login [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult Login

How to set up cookie based authentication with NancyFx and IdentityServer3 (non-API website)

眉间皱痕 提交于 2019-12-10 14:12:38
问题 We have an environment with the following: Standalone IdentityServer3 instance (issues reference tokens, not jwt) ASP.NET WebAPI resource server .NET client applications that authenticate against IdSvr (via resource owner flow) ...and now we'd like to start adding an OWIN-hosted web app that will use NancyFx to serve server-rendered pages as well as a couple AngularJS SPAs. This Nancy website will NOT host any APIs, but may consume data from our existing API. I'd like to add authentication in

Sharing Owin Cookie Authentication and legacy Forms Authentication cookie based

微笑、不失礼 提交于 2019-12-10 13:44:47
问题 In our company, we have a large base of application built with Asp.net Web Forms 4.0 that use forms authentication as a single-sign-on authentication. Configured something like this: <machineKey decryptionKey="..." validationKey="..." /> <authentication mode="Forms"> <forms cookieless="UseCookies" loginUrl="/url/to/login" /> </authentication> Last times we are working on some projects that use Owin Cookie authentication. According to the searches I did, both methods are not compatible.

Converting HttpRequestMessage to OwinRequest and OwinResponse to HttpResponseMessage

醉酒当歌 提交于 2019-12-10 13:42:52
问题 I have a web API message handler MyHandler that I want to run in OWIN pipeline as a middleware. So configuring the handler like this. public class Startup { public void Configuration(IAppBuilder app) { app.UseHttpMessageHandler(new MyHandler()); HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute( "DefaultWebApi", "{controller}/{id}", new { id = RouteParameter.Optional }); app.UseWebApi(config); } } Handler is very simple and does nothing. public class MyHandler :

SignalR server --> client call not working

半世苍凉 提交于 2019-12-10 13:26:31
问题 I'm currently using SignalR to communicate between a server and multiple separate processes spawned by the server itself. Both Server & Client are coded in C#. I'm using SignalR 2.2.0.0 On the server side, I use OWIN to run the server. I am also using LightInject as an IoC container. Here is my code: public class AgentManagementStartup { public void ConfigurationOwin(IAppBuilder app, IAgentManagerDataStore dataStore) { var serializer = new JsonSerializer { PreserveReferencesHandling =

SignalR responses overwriting headers

你。 提交于 2019-12-10 13:21:08
问题 I've built a simple SignalR hub that lives within a WebAPI service, I've included all the required CORS attributes on both WebAPI and SignalR. My WebAPI endpoints are all working as expected but SignalR isn't. I've tried all I can think of and all I can find online but nothing works, I already tried this answer, and this other to no solution. My SignalR extension method looks like this public static IAppBuilder UseSignalrNotificationService(this IAppBuilder app) { var config = new

Owin UseStaticFiles not respecting RequestPath

孤者浪人 提交于 2019-12-10 12:52:09
问题 **EDIT: NOTE: This appears to be fixed in later versions of the Owin StaticFiles middleware, so if you have this probem, simply upgrade ** My OWIN configuration has this:- string root = AppDomain.CurrentDomain.BaseDirectory; var staticFilesOptions = new StaticFileOptions(); staticFilesOptions.RequestPath = new PathString("/foo"); staticFilesOptions.FileSystem = new PhysicalFileSystem(Path.Combine(root, "web")); app.UseStaticFiles(staticFilesOptions); When I hit /foo/app/app.js I get a 404

UserManager Keeps throwing a System.ArgumentNullException

亡梦爱人 提交于 2019-12-10 12:45:55
问题 I am trying to implemented the standard Id in AspNetUsers from nvarchar to int . I've manage to get that side working. However my issue is when I try to login I keep getting an error from the UserManager class. My code is below: public class UserManager : UserManager<ApplicationUser, int> { public UserManager(IUserStore<ApplicationUser, int> store) : base(store) { } And on the login page I've got if (IsValid) { // Validate the user password var manager = Context.GetOwinContext()

Lifetime of Refresh Tokens with Katana OAuthAuthorizationServer

ぐ巨炮叔叔 提交于 2019-12-10 12:17:33
问题 From the source code sandbox Webserver, refresh tokens was done like this: RefreshTokenProvider = new AuthenticationTokenProvider { OnCreate = CreateRefreshToken, OnReceive = ReceiveRefreshToken, } private void CreateRefreshToken(AuthenticationTokenCreateContext context) { context.SetToken(context.SerializeTicket()); } private void ReceiveRefreshToken(AuthenticationTokenReceiveContext context) { context.DeserializeTicket(context.Token); } This create refresh tokens that have the same lifetime