locked
The type initializer for 'System.Net.WebUtility' threw an exception. RRS feed

  • Question


  • I have an error like below:

    [Unhandled Exception]
    System.TypeInitializationException: The type initializer for 'System.Net.WebUtility' threw an exception. ---> System.Web.HttpException
       at System.Web.CachedPathData.GetPhysicalPath(VirtualPath virtualPath)
       at System.Web.CachedPathData.GetConfigPathData(String configPath)
       at System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp)
       at System.Web.HttpContext.GetFilePathData()
       at System.Web.HttpContext.GetConfigurationPathData()
       at System.Web.HttpContext.GetSection(String sectionName)
       at System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName)
       at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey)
       at System.Configuration.ConfigurationManager.GetSection(String sectionName)
       at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
       at System.Net.Configuration.SettingsSectionInternal.get_Section()
       at System.Net.WebUtility..cctor()
       --- End of inner exception stack trace ---
       at System.Net.WebUtility.HtmlEncode(String value)
       at System.Web.Util.HttpEncoder.HtmlEncode(String value)
       at System.Web.HttpUtility.HtmlEncode(Object value)
       at System.Web.WebPages.WebPageBase.Write(Object value)
       at ASP._Page_Views_Error_StatusCode_cshtml.Execute() in d:\websites\aaa\Views\Error\aaa.cshtml:line 7
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
       at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
       at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
       at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
       at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
       at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)

    My website is in Windows server 2012. I have no idea why does it happen.
     p.s. Just sometimes the error raised. And another website which is perfectly same with this in another server(2012) has not occurred error like this.  

    The exception is being generated within framework code so it makes debugging much more difficult, since it appears to randomly happen and isn't consistently reproducable. 
    Has anyone else seen this and does anyone know a cause or solution?

    • Moved by Caillen Friday, January 23, 2015 8:56 AM
    Thursday, January 22, 2015 7:15 AM

All replies

  • Hello Emily,

    Since this exception is thrown in a web application, you would get much more help if you open up a new thread in the ASP.NET forums here:

    http://forums.asp.net/

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 23, 2015 8:56 AM