Server cannot append header after HTTP headers have been sent

Sep 18, 2015 at 6:55 AM
I've restyled some my websites using Open Url Rewrite 1.3.2 on DNN 7.4.1.
It's great and work fine but looking at IIS event log I can find a lot of exceptions, I think all linked to old bot indexed url and no more presents in the new website version.
Opening the URL reported in the exception I can see the right 404 page configured in Open UrlRewriter and no one issue is reported on browser.
I have to worry about this problem? How I can fix it?
Below you can see one of this reported exceptions:
*********************************************************************

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 9/18/2015 4:50:39 AM 
Event time (UTC): 9/18/2015 2:50:39 AM 
Event ID: d76b3f2e1f74430491784dbbaee57c00 
Event sequence: 776 
Event occurrence: 8 
Event detail code: 0 
 
Application information: 
    Application domain: /LM/W3SVC/12/ROOT-1-150870047247212163 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: C:\inetpub\DNN741\ 
    Machine name: WEB002 
 
Process information: 
    Process ID: 4496 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\DNN741 
 
Exception information: 
    Exception type: HttpException 
    Exception message: Server cannot append header after HTTP headers have been sent.
   at System.Web.HttpResponse.AppendHeader(String name, String value)
   at Satrabel.HttpModules.UrlRewriteModuleUtils.RewriteUrl(HttpApplication app, Uri url, String& portalAlias, PortalAliasInfo& objPortalAlias, RewriterAction& action, String applicationPath, Boolean isSecureConnection, String httpMethod, String rawUrl, String PhysicalPath)
   at Satrabel.HttpModules.UrlRewriteModuleUtils.RewriteUrl(HttpApplication app, String& portalAlias, PortalAliasInfo& objPortalAlias, RewriterAction& action)
   at Satrabel.HttpModules.UrlRewriteModule.RewriteUrl(HttpApplication app, String& portalAlias)
   at Satrabel.HttpModules.UrlRewriteModule.OnBeginRequest(Object s, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

 
 
Request information: 
    Request URL: http://www.mywebsite.com/Products/tabid/83/agentType/View/WorkID/4/SoftWork.aspx 
    Request path: /Products/tabid/83/agentType/View/WorkID/4/SoftWork.aspx 
    User host address: 60.168.59.196 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: IIS APPPOOL\DNN741 
 
Thread information: 
    Thread ID: 3 
    Thread account name: IIS APPPOOL\DNN741 
    Is impersonating: False 
    Stack trace:    at System.Web.HttpResponse.AppendHeader(String name, String value)
   at Satrabel.HttpModules.UrlRewriteModuleUtils.RewriteUrl(HttpApplication app, Uri url, String& portalAlias, PortalAliasInfo& objPortalAlias, RewriterAction& action, String applicationPath, Boolean isSecureConnection, String httpMethod, String rawUrl, String PhysicalPath)
   at Satrabel.HttpModules.UrlRewriteModuleUtils.RewriteUrl(HttpApplication app, String& portalAlias, PortalAliasInfo& objPortalAlias, RewriterAction& action)
   at Satrabel.HttpModules.UrlRewriteModule.RewriteUrl(HttpApplication app, String& portalAlias)
   at Satrabel.HttpModules.UrlRewriteModule.OnBeginRequest(Object s, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
 
 
Custom event details: 

*********************************************************************
Coordinator
Sep 19, 2015 at 10:00 AM
Hi,

It's difficult to tell you what the real origin of this exception.

Because openurlrewriter executes in one of the first steps of the asp.net pipelines. So this exceptions can't happend.

The only raison i can imagine, is that a other thing (iis, hhtpmodules,...) end the pipelines before openurlrewriter, so when openurlrewriter try to append a header a exception occurs.

If you can not reproduce the error now. You don't worry.

Regards,
Sacha
Sep 21, 2015 at 2:27 PM
Edited Sep 21, 2015 at 2:30 PM
I think you're wrong, I have many installations with different DNN versions and nothing shows this type of exceptions on IIS event log.
Only the installation with Open Url Provider presents such problems. Have you tried to call some inexistent url to see if the exception is reported also in your IIS event log?
I've read that the problem may be caused when in the code it is not setted response.isbuffered = true
Coordinator
Sep 22, 2015 at 3:00 PM
Hi,

Do you have a public url where this exception occurs ?

When this exception occurs, what is then returned by the server ? A working page ? A status 500 ?

Regards,
Sacha
Sep 22, 2015 at 4:26 PM
Edited Sep 22, 2015 at 4:48 PM
Yes sure, some inexistent URLs but not any 404 URLs, I sent you some example public URL in private message.
When the exception occurs I can't see the right 404 page how bad written on the first post but I'm redirect to the home page but not for all url with exception some do see the right 404 page. When I enter some others invalid url I'm instead normally redirected to the right 404 page, I don't understand the reason and the difference!
Something go bad!
Sep 22, 2015 at 4:49 PM
Edited Sep 22, 2015 at 4:54 PM
I'm sorry but I have to correct me! I just found an exception for an existing URL corresponding to a real page on the site!
Moreover not always the exception is thrown to the same URL!
Exceptions occur randomly!