﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Sebastien Ros commented on Hunt the bug</title><description>There has been some changes in .NET 4 which introduced this bug. I hit it when we switched our solution to VS2010. So as it's actually forgetting to check HttpContext.Current null values before using it, we hacked this by assigning a mock HttpContext around it.
  
  
Sebastien
  
</description><link>http://ayende.com/4599/hunt-the-bug#comment5</link><guid>http://ayende.com/4599/hunt-the-bug#comment5</guid><pubDate>Sat, 21 Aug 2010 14:14:33 GMT</pubDate></item><item><title>tobi commented on Hunt the bug</title><description>This means that the context _is_ available but it is a fake one - getting the response throws. My workaround that I posted is still valid ;-)
</description><link>http://ayende.com/4599/hunt-the-bug#comment4</link><guid>http://ayende.com/4599/hunt-the-bug#comment4</guid><pubDate>Sat, 21 Aug 2010 14:10:28 GMT</pubDate></item><item><title>Victor Kornov commented on Hunt the bug</title><description>Yep, starting .NET 4 HttpUtility requires a HttpContext /HttpResponse wich is not yet available at the time of Application_Start with IIS7 in integrated mode. I guess the stack trace looks like:
  
  
[HttpException (0x80004005): Response is not available in this context.]
  
   System.Web.HttpContext.get_Response() +8753496
  
   System.Web.Util.HttpEncoder.get_Current() +39
  
   System.Web.HttpUtility.UrlEncodeToBytes(String str, Encoding e) +31
  
   System.Web.HttpUtility.UrlEncode(String str) +41
  
   Global.Application_Start(Object sender, EventArgs e)
</description><link>http://ayende.com/4599/hunt-the-bug#comment3</link><guid>http://ayende.com/4599/hunt-the-bug#comment3</guid><pubDate>Sat, 21 Aug 2010 11:40:03 GMT</pubDate></item><item><title>Artur commented on Hunt the bug</title><description>I'm guessing that HttpUtility underneath requires an HttpContext and that might not be present at Application_Start.
</description><link>http://ayende.com/4599/hunt-the-bug#comment2</link><guid>http://ayende.com/4599/hunt-the-bug#comment2</guid><pubDate>Sat, 21 Aug 2010 11:16:49 GMT</pubDate></item><item><title>tobi commented on Hunt the bug</title><description>I guess it has to do with the new HttpEncoder support. I can be disabled by setting Response.DisableCustomHttpEncoder but that is not available in application start. You could have used HttpEncoder.Default however.
</description><link>http://ayende.com/4599/hunt-the-bug#comment1</link><guid>http://ayende.com/4599/hunt-the-bug#comment1</guid><pubDate>Sat, 21 Aug 2010 09:31:36 GMT</pubDate></item></channel></rss>