在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符。 (异常来自 HRESULT:0x80070459) 
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentOutOfRangeException: 在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符。 (异常来自 HRESULT:0x80070459)
[没有相关的源行] 源文件: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\2d1ee80e\52146ed9\App_Web_l4lsnkxq.0.cs    行: 0 堆栈跟踪: [ArgumentOutOfRangeException: 在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符。 (异常来自 HRESULT:0x80070459)]
   System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) +0
   System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal(String name) +98
   System.Web.Hosting.IIS7WorkerRequest.ReadRequestHeaders() +134
   System.Web.Hosting.IIS7WorkerRequest.GetKnownRequestHeader(Int32 index) +153
   System.Web.HttpRequest.FillInHeadersCollection() +145
   System.Web.HttpRequest.get_Headers() +217
   System.Web.Configuration.HttpCapabilitiesDefaultProvider.EvaluateFinal(HttpRequest request, Boolean onlyEvaluateUserAgent) +60
   System.Web.Configuration.HttpCapabilitiesDefaultProvider.Evaluate(HttpRequest request) +413
   System.Web.HttpRequest.get_Browser() +260
   System.Web.UI.Page.SetIntrinsics(HttpContext context, Boolean allowAsync) +214
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +19
   System.Web.UI.Page.ProcessRequest(HttpContext context) +167
   ASP.login_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\2d1ee80e\52146ed9\App_Web_l4lsnkxq.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +625
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270
 
请问这是什么原因

解决方案 »

  1.   

    当我们asp.net程序迁移到iis7时,如果页面cookie中存在未编码的汉字时,iis内核就会报错,错误信息如下:在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符。 (异常来自 HRESULT:0x80070459)对应的英文错误信息如下:No mapping for the Unicode character exists in the target multi-byte code page 经过单元测试,确实如此,iis6下还未测试,不知是否会发生此情况 解决方案:存储cookie值经过url编码即可,上代码
    HttpCookie cookie = new HttpCookie("username", HttpUtility.UrlEncode(userName));
                        cookie.Expires = DateTime.Now.AddMonths(1);
                        Response.AppendCookie(cookie);