I have a web service that's already written using conventional WebApi under IIS. I'm trying to make it run under Katana. The one little problem I'm having is that I have a gateway component deep down (retrieved via IoC) that looks at request headers via HttpContext.Current. Yes, I know that's not ideal from a testability standpoint, but it was somewhat of a late-in-the-game hack. But as you could imagine, that's causing me trouble under Katana which doesn't populate HttpContext.Current.So how can I access headers from down there?
That's true, though, there's an awfully short supply of information out there.
On Wed, Mar 13, 2013 at 8:07 PM, Chris R <trat...@hotmail.com> wrote:
The most up to date middleware pattern samples can be found here:There are also a handful of Katana samples on http://aspnet.codeplex.com/.Let me know if there are major any major gaps.
Date: Wed, 13 Mar 2013 13:56:59 -0700
From: t...@schmidthole.com
To: net-http-a...@googlegroups.com
Subject: Re: Code accessing HttpContext.Current
N00b question. Documentation on Owin/Gate/Katana seems scarce at best and the samples are littered with extension methods that either don't exist anymore or that are marked internal. Is there some guidance on how to create middleware components?In regards to my original question, I noticed that my ControllerContext (where I'm using my component from) is populated both under asp.net and katana, so I may just use that to call into my component. Either by passing the components to each method (which seems ugly) or by feeding them into IoC or something... not sure yet.
On Tuesday, March 12, 2013 3:01:36 PM UTC-5, Louis DeJardin wrote:Ouch, evil!Well, one thing you could consider is re-create a pseudo-static property you could access. So if you made a public static IDict<string,object> OwinHttpContext.Current property, and a middleware class which set it going in and cleared it coming out, then your component could use that instead to get the "current" environment.The tricky part when you implement the Current get/set methods is where to store the value. Thread static breaks down if any of the task work is async - but you might have some of the apis like CallContext.LogicalSetData/LogicalGetData. I believe those values will flow along even if you are async thread-hopping.
On Tuesday, March 12, 2013 12:50:22 PM UTC-7, Tim Schmidt wrote:I have a web service that's already written using conventional WebApi under IIS. I'm trying to make it run under Katana. The one little problem I'm having is that I have a gateway component deep down (retrieved via IoC) that looks at request headers via HttpContext.Current. Yes, I know that's not ideal from a testability standpoint, but it was somewhat of a late-in-the-game hack. But as you could imagine, that's causing me trouble under Katana which doesn't populate HttpContext.Current.So how can I access headers from down there?
--
You received this message because you are subscribed to the Google Groups ".NET HTTP Abstractions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-http-abstractions+unsub...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups ".NET HTTP Abstractions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-http-abstractions+unsub...@googlegroups.com.