[SPRNET-1446] WebContextHandler returns "Request is not available in this context" under IIS7 + Integrated Pipeline mode Created: 01/Jun/11  Updated: 16/Apr/12

Status: Reopened
Project: Spring.NET
Component/s: Spring-NET-WEB
Affects Version/s: 1.3.0, 1.3.1
Fix Version/s: 1.3.2

Type: Bug Priority: Major
Reporter: Steve Bohlen Assignee: Steve Bohlen
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relate
is related to SPRNET-1443 Support for ASP.NET MVC3 Resolved

 Description   

Changes in the lifecycle of the the scope of the HttpContext.Request object under IIS7 in integrated pipeline mode result in "Request is not available in this context" exceptions when the Request is depended upon in Application_Start(). This has broken WebContextHandler in this use-case.

See http://mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this-context-in-Application_5F00_Start.aspx for info on a possible pattern employed to address the issue of attempting to access the HttpContext.Request object before its been properly created under IIS7 + integrated pipeline mode. This pattern was successfully employed to resolve a similar issue for the MvcContextHandler under SPRNET-1443.



 Comments   
Comment by Erich Eichinger [ 03/Jun/11 ]

do you have a stacktrace? as mentioned there is a fix in place, on some occasions it seems though that this fix doesnt catch a particular scenario. I need to know what exactly this scenario is

Comment by Steve Bohlen [ 04/Jun/11 ]

After further investigation, it turns out this issue was only appearing in mixed WebForms and MVC3 applications and was actually also fixed by the subsequent work in SPRNET-1443 to address the same error condition under MVC3. In MVC3, the container init would (by default) happen too soon in the ASP.NET application lifecycle where the REQUEST object was not yet in scope. Fixing this under MVC3 as in SPRNET-1443 has alredy 'fixed' this for the mixed-use application case as well.

Comment by Doan Van Tuan [ 21/Mar/12 ]

Hi Erich,
In my project, when using the container (ContextRegistry.GetContext()) in Application_Start, I still encounter this dreaded exception. Could you please give me some information about this particular issue? If you need a project that shows the exception, I can send you one.

Comment by Steve Bohlen [ 16/Apr/12 ]

If you have a project that demonstrates this issue (reliably!) can you please zip it up and attach it to this issue? Thanks~!

Comment by Steve Bohlen [ 16/Apr/12 ]

There is a new report that this issue still exists, so re-opening it to track it (again).

Generated at Tue Nov 12 01:03:31 UTC 2019 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.