I have developed an IIS Application using C# code behind ASPX pages with entity framework for database access. 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
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. Some simple ASPX pages work ok. Setting a NullReferenceException break point just drops into disassembly.
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.
It's worth knowing that having nulls in Response.AddHeader() causes this kind of problem rather than handling the null more gracefully.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.