简体   繁体   English

IIS NullReferenceException部署时但不在Dev Server中

[英]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.

相关问题 HttpContext.User NullReferenceException 仅在部署的服务器上 - HttpContext.User NullReferenceException only on deployed server System.NullReferenceException for .NET 服务在 Windows Server IIS 上运行,但在 Visual Studio IIS Express 中运行时在本地工作 - System.NullReferenceException for .NET service running on windows server IIS but works locally when running in Visual Studio IIS Express 使用实体框架进行联接时发生NullReferenceException,但仅在部署时 - NullReferenceException when doing a Join using Entity Framework, but only when deployed Azure应用程序可在开发架构上运行,但在部署时无法运行 - Azure app works on dev fabric but not when deployed (.net 核心 MVC)Model 在表单发布后返回 null 但仅当部署到本地 IIS 服务器时 - (.net core MVC) Model is being returned null after form post but only when deployed to on premise IIS server 当代码部署在Windows Server 2003框中的IIS 6.0上时,LoadLibraryEx在c#中返回0 - LoadLibraryEx returns 0 in c# when the code was deployed on IIS 6.0 in windows server 2003 box “由于内部错误,服务器无法处理请求”。 WCF 服务,在 IIS 上部署时 - 'The server was unable to process the request due to an internal error'. WCF Service, when deployed on IIS ASP.NET IIS服务器警告应用程序错误NullReferenceException - ASP.NET IIS server warning Application Error NullReferenceException 在IIS8中部署时,缓存不起作用 - Caching not working when deployed in IIS8 部署到IIS时,We​​bApi对数据库的访问失败 - WebApi access to database fails when deployed to IIS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM