[英]IIS NullReferenceException when deployed but not in Dev Server
I have developed an IIS Application using C# code behind ASPX pages with entity framework for database access. 我已经使用ASPX页面后的C#代码以及用于数据库访问的实体框架开发了一个IIS应用程序。 When I run it in the Visual Studio Development Server it works fine but if I either Publish it to IIS or run it on the Local IIS Web Server from Visual Studio (which is pretty much the same as Publishing I guess) I get
当我在Visual Studio Development Server中运行它时,它可以很好地工作,但是如果我将其发布到IIS或从Visual Studio在本地IIS Web服务器上运行(我猜它与发布几乎相同),我会得到
NullReferenceException: Object reference not set to an instance of an object.]
System.Web.Hosting.RecyclableCharBuffer.Append(String s) +15
System.Web.Hosting.ISAPIWorkerRequest.SendUnknownResponseHeader(String name, String value) +93
System.Web.HttpResponse.WriteHeaders() +233
System.Web.HttpResponse.Flush(Boolean finalFlush) +219
System.Web.HttpRuntime.FinishRequest(HttpWorkerRequest wr, HttpContext context, Exception e) +127
This Exception is thrown after my Home.aspx has finished it's Page Load. 我的Home.aspx完成页面加载后会引发此异常。 Some simple ASPX pages work ok.
一些简单的ASPX页面可以正常工作。 Setting a NullReferenceException break point just drops into disassembly.
设置NullReferenceException断点只会导致反汇编。
I am stuck for ideas about how to track this issue down. 我对如何跟踪此问题的想法感到困惑。 Any thoughts???
有什么想法吗???
Finally tracked this down. 终于找到了答案。 Some of out template code in the master page was doing
母版页中的某些模板代码正在执行
Response.AddHeader("X-UA-Compatible", (String)Application["X-UA-Compatible"]);
when Published Application["X-UA-Compatible"] was null. 当发布的应用程序[“ X-UA-Compatible”]为空时。
It's worth knowing that having nulls in Response.AddHeader() causes this kind of problem rather than handling the null more gracefully. 值得知道的是,在Response.AddHeader()中包含null会导致这种问题,而不是更优雅地处理null。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.