owin

Owin SelfHost WebApi - client closing the connection during response raises an exception?

≡放荡痞女 提交于 2019-12-03 23:24:56
I'm running an Owin Selfhost based WebApi where i've put in an API unhandled exception logger via config.Services.Add(typeof(IExceptionLogger), _apiExceptionLogger); Relevant part of ApiExceptionLogger: public override void Log(ExceptionLoggerContext context) { if (context == null || context.ExceptionContext == null) return; Logger.Error("Unhandled exception from Web API", context.ExceptionContext.Exception); } The cases it's catching and logging regularly are ones where the client requests a dataset and then closes the connection while the results (JSON) are being sent back - people making a

OWIN app.use vs app.run vs app.map

人盡茶涼 提交于 2019-12-03 22:49:19
What's the difference among app.use , app.run , app.map in Owin ? When to use what? It's not straightforward when reading the documentation. app.use inserts a middleware into the pipeline which requires you to call the next middleware by calling next.Invoke(). app.run inserts a middleware without a next, so it just runs. With app.map you can map paths, which get evaluated at runtime, per request, to run certain middleware only if the request path matches the pattern you mapped. See docs for use and run and map for more details app.Run The nature of Run extension is to short circuit the HTTP

Access ExpireTimeSpan property of Owin Cookie Authentication to notify user of login expiry

▼魔方 西西 提交于 2019-12-03 20:54:21
问题 I am using Owin's cookie authentication to logout users after a time period of inactivity. The thing is, I need to let the user know that their session expires in 'X' minutes. How can I access the authentication cookie to get the time remaining? Is this even possible? Has anybody had to do something like this before? 回答1: It is possible. One way to do that would be to use the OnValidateIdentity callback, which is called every time the cookie is authenticated, which is every time a request is

SignalR client is reconnected after Owin restart, but message is not published

我怕爱的太早我们不能终老 提交于 2019-12-03 20:10:38
问题 Setup: SignalRServer console app: Microsoft.AspNet.SignalR.SelfHost v2.0.3 SignalRClient console app: Microsoft.AspNet.SignalR.Client v2.0.3 .NET 4.5.1 I do the following: Hit enter on client, a message is received at server and on client again Dispose the server by hitting any key in the server console Restart the server by hitting any key in the server console Client is reconnected Hit enter on client, message is received at server, but never reaches the client again I expect the message to

Owin provide startup class in web.config (no automatic startup discovery)

↘锁芯ラ 提交于 2019-12-03 19:27:15
问题 I try to do the following in my web.config: <appSettings> <add key="owin:AutomaticAppStartup" value="false" /> <add key="owin:appStartup" value="MyNamespace.MyStartupClass" /> </appSettings> If I understand this documentation correctly automatic startup detection should be disabled. So I do not require a startup attribute. Unfortunately it looks like OWIN does not start. (I see this because I get the error: HTTP Error 403.14 - Forbidden . I use a controller to handle requests to the index

Changing the response object from OWIN Middleware

偶尔善良 提交于 2019-12-03 19:00:53
问题 My OWIN middleware is like this. (Framework is ASP.NET Web API). public class MyMiddleware : OwinMiddleware { public MyMiddleware(OwinMiddleware next) : base(next) { } public override async Task Invoke(OwinRequest request, OwinResponse response) { var header = request.GetHeader("X-Whatever-Header"); await Next.Invoke(request, response); response.SetHeader("X-MyResponse-Header", "Some Value"); response.StatusCode = 403; } } Questions: Is it the recommended practice to derive from

Current user in owin authentication

别说谁变了你拦得住时间么 提交于 2019-12-03 18:32:28
问题 I started to build a web api for mobile apps and I'm having a hard time with implementing authentication. I use Bearer and although everything is supposed to be fine, I cannot get the current user from action in controller. HttpContext.Current.User.Identity.Name is null (the same is result of HttpContext.Current.User.Identity.GetUserId()). Here are the pieces of important code: Startup.cs: public partial class Startup { public void Configuration(IAppBuilder app) { var config = new

Logging out from facebook when using MVC 5 OWIN

醉酒当歌 提交于 2019-12-03 17:34:16
I have an MVC 5 web app that has facebook authentication set up and working nicely. User clicks "Facebook" on the login page, signs in to Facebook and that authenticates with our web site. If the user logs out, the call to AuthenticationManager.SignOut() logs out of the web site correctly, but if the user then goes back to the login page and clicks "Facebook" again they are immediately signed in without having to sign in to facebook. So my question is, how do I configure MVC 5 OWIN facebook login so that the user is signed out of facebook when they sign out of the web site, or to put it

Creating Owin Auth Provider that Exchanges a Custom Token for a .Net Auth Cookie

时光总嘲笑我的痴心妄想 提交于 2019-12-03 17:21:06
I am trying to create an SSO like solution between 2 .Net applications .Net app 1 has a custom token generator and endpoints to validate tokens that returns user information. .Net application 2 is protected using Owin and was a typical standalone app and a user would directly login using a password and username. I created (based on Passion for Coding Blog and Github ) a custom Owin provider that would look for a token either in a Authorization header or as a query parameter from a link that a user would click a link from .Net App 1 and send to the .Net App 2 the token in the query string as at

Mixed mode authentication with OWIN

a 夏天 提交于 2019-12-03 16:51:36
I am building an MVC 5 application. I need to authenticate people against an AD and a sql data base or a web service. Requirement is if a person is logged into corporate network or conneted over VPN i have to log them without asking for credentials. if the users are accessing the web site over internet or a person do not have AD account i have to use forms authentication. I am looking at this article but will this work with ASP.Net MVC and OWIN? Any other alternative? Thanks in advance. I'm doing something very similar at the moment too. I'm providing a single sign-on portal for internal and