HttpUtility.HtmlEncode() fails in Application_Start with "Response is not available in this context" - by Joshua Flanagan

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 578670 Comments
Status Closed Workarounds
Type Bug Repros 11
Opened 7/26/2010 3:50:00 PM
Access Restriction Public


The HttpUtility encoding methods cannot be used with Application_Start. They work correctly in a console application (when no HttpContext exists), but fail within a web application (where HttpContext is not null) when a Request is not being processed.
This works correctly when running under .NET 2.0.
Sign in to post a comment.
Posted by Damian [MSFT] on 7/6/2012 at 3:38 PM
This is fixed in ASP.NET 4.5.
Posted by doyle_am on 3/8/2011 at 2:56 AM
What is the procedure for obtaining a resolution to this now that the issue is closed? I'm unable to find a related hotfix or patch for either VS2010 or IIS.
Posted by Doug Wilson ( on 11/10/2010 at 2:55 PM
I see this as well on an ASP.NET project that we are upgrading to .NET 4. This behavior is only visible under IIS - the VS Web Dev Server works as expected. We see this under both Windows 7 x64 and Windows Server 2008 x64.
Posted by William Gross on 10/15/2010 at 2:00 PM
I can reproduce this bug as well. When will the fix be available?
Posted by Joshua Flanagan on 8/11/2010 at 9:05 AM
I see this issue has been marked as Closed/Fixed. Will the issue be updated with details of how the fix will be delivered (hotfix, service pack, next product release, etc)?
Posted by Microsoft on 7/27/2010 at 7:21 PM
Thanks again for your feedback.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution.These specialized experts will follow-up with your issue.
Posted by Joshua Flanagan on 7/27/2010 at 8:05 AM
I have attached a zip file that contains a Web Site project, and a screenshot of the error.

Make sure you run the website under IIS (NOT the Visual Studio web server).

I am running on IIS on Windows 7 x64 and see the error every time.
Posted by Microsoft on 7/27/2010 at 3:23 AM
Thank you for reporting this issue.
But we were not able to reproduce it with the steps you provided. Could you please attach a demo project and some screenshots to help us investigate this issue?
Posted by Microsoft on 7/26/2010 at 5:04 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(