Questions tagged [owin-middleware]

OWIN Middleware in the IIS integrated pipeline

266 questions
43
votes
2 answers

Why middleware in ASP.NET Core requires specific semantics, but not an interface?

As known, IApplicationBuilder of the method Configure (class Startup) in ASP.NET Core requires specific semantics (to have method 'Invoke' with input parameter of HttpContext type and Task as return value). But why it's not implemented as interface?…
Oleg Sh
  • 8,496
  • 17
  • 89
  • 159
39
votes
3 answers

Global exception handling in OWIN middleware

I'm trying to create a unified error handling/reporting in ASP.NET Web API 2.1 Project built on top of OWIN middleware (IIS HOST using Owin.Host.SystemWeb). Currently I used a custom exception logger which inherits from…
35
votes
4 answers

Rewind request body stream

I am re-implementing a request logger as Owin Middleware which logs the request url and body of all incoming requests. I am able to read the body, but if I do the body parameter in my controller is null. I'm guessing it's null because the stream…
Despertar
  • 21,627
  • 11
  • 81
  • 79
34
votes
2 answers

ASP.NET Core middleware or OWIN middleware?

As I understand it, ASP.NET Core has support for OWIN middleware (via app.UseOwin()) in addition to its own native middleware. What is the difference between ASP.NET Core middleware and OWIN middleware? When designing a new middleware, how do I know…
Fred
  • 12,086
  • 7
  • 60
  • 83
24
votes
1 answer

How can I safely intercept the Response stream in a custom Owin Middleware

I'm trying to write a simple OWIN Middleware, in order to intercept the response stream. What I'm trying to do is replace the original stream with custom Stream-based class, where I will be able to intercept writes to the response stream. However,…
Maxime Labelle
  • 3,609
  • 2
  • 27
  • 48
21
votes
1 answer

Should I use OwinContext's Environment to hold application specific data per request

I need a way to store a logging object per request. With HttpContext I would add this to the items Dictionary. I don't want to bring HttpContext into this if I can help it. The below code is what I propose for a Unity LifeTimeManager that will store…
codetoast
  • 293
  • 1
  • 2
  • 9
19
votes
2 answers

Middleware to set response ContentType

In our ASP.NET Core based web application, we want the following: certain requested file types should get custom ContentType's in response. E.g. .map should map to application/json. In "full" ASP.NET 4.x and in combination with IIS it was possible…
Matthias
  • 3,403
  • 8
  • 37
  • 50
15
votes
4 answers

How to intercept 404 using Owin middleware

Background First let me explain the background. I am working on a project that attempts to marry a backend server that uses Web API configured via OWIN- hosted on IIS now, but potentially other OWIN-supported hosts in the future- to a frontend using…
moribvndvs
  • 42,191
  • 11
  • 135
  • 149
14
votes
3 answers

How and when does Configuration method in OwinStartup class is called/executed?

Before I ask my question I have already gone through the following posts: Can't get the OWIN Startup class to run in IIS Express after renaming ASP.NET project file and all the posts mentioned in the question. OWIN Startup…
phougatv
  • 881
  • 2
  • 12
  • 29
10
votes
3 answers

ASP.NET OWIN OpenID Connect not creating user authentication

I have an ASP.NET 4.6 web app that I'm trying to add OpenId Connect using OWIN. I added my Owin startup class and everything appears to be configured correctly, but the problem I'm having is the ASP Identity/Authenticated user never gets created. I…
swbradshaw
  • 874
  • 9
  • 15
10
votes
1 answer

Change OWIN Auth Middleware Per Request (Multi-tenant, oauth API keys per tenant)

I have a multi-tenant application. Each tenant can authenticate its users using OAUTH-2 with Facebook, Twitter, Google, etc. Each tenant has its own API keys for the aforementioned services. The typical way to setup the OWIN pipeline is to "use"…
kingdango
  • 3,979
  • 2
  • 26
  • 43
9
votes
1 answer

Can I add a new scoped service within a custom middleware?

I'm using WebApi in Asp .Net Core and I'm wondering if/how I can add a new scoped service that all following middleware and controllers can get access to through dependency injection? Or should I share state with HttpContext.Items instead? That…
Andreas Zita
  • 7,232
  • 6
  • 54
  • 115
9
votes
3 answers

Add claims with Owin Middleware

Is it possible with an Owin Middleware implementation to add claims prior to the execution of a Web API controller? Created an OwinMiddleware implementation and added an identity: var id = new ClaimsIdentity(); id.AddClaim(new Claim("Whatever",…
8
votes
2 answers

SSO with Azure ADFS and OWIN

Thank you for providing help. I have a site that can authenticate with Active Directory Federated Services for Single Sign On. Currently, the way my site works is that, by default, when a user hits my site, my code attempts to log then into SSO (I…
jason
  • 3,821
  • 10
  • 63
  • 120
8
votes
1 answer

Why use OWIN TestServer?

This article shows how to host an entire web API stack in memory for testing using OWIN: http://www.davidwhitney.co.uk/Blog/2015/01/07/testing-an-asp-net-webapi-app-in-memory/ Whereas this article shows using the OWIN TestServer to unit test…
Matt W
  • 11,753
  • 25
  • 118
  • 215
1
2 3
17 18