I have a Asp net web site. sometimes (I don't know when) it threw an exception. (to the browser it sends 404 error).

The type initializer for 'System.Net.WebUtility' threw an exception. 
at System.Net.WebUtility.HtmlEncode(String value) 
at System.Web.Util.HttpEncoder.HtmlEncode(String value) 
at System.Web.UI.HtmlControls.HtmlContainerControl.set_InnerText(String value) 
at Results.DefineCheckboxFilter(String filterName, String param, Boolean createHidden) in d:\HostingData\chani.poz\macher.co.il\wwwroot\App_Code\Results.cs:line 79 
at Controls_NadlanFilter.InitialFilter() in d:\HostingData\chani.poz\macher.co.il\wwwroot\Controls\NadlanFilter.ascx.cs:line 50 
at Controls_NadlanFilter.Page_Load(Object sender, EventArgs e) in d:\HostingData\chani.poz\macher.co.il\wwwroot\Controls\NadlanFilter.ascx.cs:line 31 
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) 
at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() 
at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() 
at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)System.Web Exception of type 'System.Web.HttpUnhandledException' was thrown.

The DefineCheckboxFilter function is in Results class. in the function line 79 (The line that threw the exception)

HtmlGenericControl ht = (HtmlGenericControl)ls.FindControl("HasterGale" + filterName);
ht.InnerText = "הסתר";

p.s. The problem occurs even if I don't in this page, and then I get the same webutility exception with other details. For example:

The type initializer for 'System.Net.WebUtility' threw an exception. 
    at System.Net.WebUtility.HtmlDecode(String value) 
    at System.Web.Util.HttpEncoder.HtmlDecode(String value) 
    at System.Web.UI.TemplateParser.ProcessAttributes(String text, Match match, ParsedAttributeCollection& attribs, Boolean fDirective, String& duplicateAttribute) 
    at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) 
    at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)System.Web The type initializer for 'System.Net.WebUtility' threw an exception.
有帮助吗?

解决方案 2

I found the answer at last:
The problem was because I have a website that define like webSite in visual studio (not webPage or something like that). and so I need to define in the server not Intagrate PipeLine. That all.

其他提示

It's a .NET Framework error. It should be corrected in Hotfix rollup 2848799.

http://support.microsoft.com/kb/2848799

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top