2013-11-20 24 views
1

我有這樣的錯誤:爲「System.Net.WebUtility」的類型初始值引發了異常

的類型初始爲「System.Net.WebUtility」引發了異常。 System.Web.Util.HttpEncoder.HtmlEncode(String value)在System.Web.UI.HtmlControls.HtmlContainerControl.set_InnerText(String value)在HomePage_index.Page_Load上的System.Net.WebUtility.HtmlEncode(String value) EventArgs e)在c:\ inetpub \ vhosts \ macher.co.il \ httpdocs \ HomePage \ index.aspx.cs中:第16行System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,EventArgs e)在System.Web在System.Web.UI.Control.LoadRecursive()上的.UI.Control.OnLoad(EventArgs e)在System.Web.UI.Page.ProcessRequestMain(布爾includeStagesBeforeAsyncPoint,布爾includeStagesAfterAsyncPoint)System.Web類型'System.Web的異常。 HttpUnhandledException'被拋出。

我的網站在vps服務器。我不知道爲什麼會發生。 p.s.只是有時候,錯誤引發

編輯: 我從我的頁面上刪除該行16,所以我同樣的錯誤,但沒有提及具體的頁面行。雖然我注意到在輸入到Web_Application func之前發生的錯誤Global.asax

+0

某些存儲在某處的字符串有一些引發此異常的無效字符。幾乎每個服務器控件都使用這種HtmlEncode方法。你應該發佈更多的信息 – Fals

+0

@Fals,它發生在**所有**在文件中,而不是在根上的頁面。所以我認爲問題是全球性的,哪些信息給予? –

+0

鑑於它是全球性的,您應該開始查看母版頁。可靠的一些控制是收到一些無效字符。 – Fals

回答

0

我剛剛親身體驗過它。我的堆棧跟蹤如下。

大家應該注意,這是拋出錯誤的類型初始值設定項/靜態構造函數。用戶代碼可以做的事情並不多。

大約3個月前,我們在我們的服務器上安裝了.net 4.5,但從現在起一直沒有問題。

特別感興趣的是pages元素上的controlRenderingCompatibilityVersion attrib。我可以嘗試刪除它,看看它是否有幫助。

其他信息是在這裏: http://forums.asp.net/t/1863996.aspx?The+type+initializer+for+System+Net+WebUtility+threw+an+exception

我可以看到,如果我有一個支持事件信用卡或登錄一個連接的文章如果我不能再找到任何東西。

我意識到這不是一個答案,但直到找到一個解決方案,我想張貼超出評論框的限制。

堆棧跟蹤:

System.TypeInitializationException:爲 'System.Net.WebUtility' 的類型初始值引發異常。 ---> System.Web.HttpException 在System.Web.CachedPathData.GetPhysicalPath(VirtualPath virtualPath) 在System.Web.CachedPathData.GetConfigPathData(字符串用configPath) 在System.Web.HttpContext.GetFilePathData() 在系統。 Web.HttpContext.GetSection(字符串sectionName) 在System.Configuration.ConfigurationManager.GetSection(字符串sectionName) 在System.Configuration.PrivilegedConfigurationManager.GetSection(字符串sectionName) 在System.Net.Configuration.SettingsSectionInternal.get_Section() 在System.Net.WebUtility..cctor() ---內部異常堆棧跟蹤結束--- at System.Net.WebUtility.HtmlEncode(String value,TextWriter output) System.Web.UI.ClientScriptManager.RenderHiddenFields(HtmlTextWriter writer) at System.Web.UI.Page.BeginFormRender(HtmlTextWriter writer,String formUniqueID) at System.Web.UI.HtmlControls。HtmlForm.RenderChildren(HtmlTextWriter作家) at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter作家) 在System.Web.UI.Control.RenderControlInternal(HtmlTextWriter作家,ControlAdapter適配器) 在System.Web.UI。 Control.RenderChildrenInternal(HtmlTextWriter writer,ICollection children) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,ControlAdapter adapter) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,ICollection children) at System。 Web.UI.Page.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,ControlAdapter adapter) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)

相關問題