.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Server cannot append header after HTTP headers have been sent

Posted By:      Posted Date: September 04, 2010    Points: 0   Category :ASP.Net
Can some one please help me with this issue- I am writing exceptions to event log, and my event log is filled with this exception messageSystem.Web.HttpException: Server cannot append header after HTTP headers have been sent.    at System.Web.HttpResponse.AppendHeader(String name, String value)    at System.Web.HttpResponse.AddHeader(String name, String value)    at AddFormPopUp.streamingFiles(String DocID, String FilePath, String FileExtension1)  Here is the code in streamingFiles function.Response.Clear() Dim binReader As New BinaryReader(File.Open((strFileNamePath), FileMode.Open, FileAccess.Read)) binReader.BaseStream.Position = 0 Dim binFile As Byte() binFile = binReader.ReadBytes(Convert.ToInt32(binReader.BaseStream.Length)) binReader.Close() Dim fileStream As New FileStream(strFileNamePath, FileMode.Open, FileAccess.Read) fileStream.Read(binFile, 0, fileStream.Length) Response.AddHeader("content-disposition", "attachment; filename=" & Strfilenameonly) Response.OutputStream.Write(binFile, 0, binFile.Length) fileStream.Close() If Response.IsClientConnected Then Response.Flush() binFile = Nothing Response.Clear() response.end  

View Complete Post

More Related Resource Links

How to read the custom http header



I have just joined the forum. I have a very simple query. I have added custom header to my website. Now I want to read the custom header. I am using IIS 6.0 on windows XP. I have already tried using using the Request.ServerVariables and and Request.header method. But none of them give me the custom header added to website.

Can any body help?

Thanks a lot in advance



A connection could not be made to the report server http://localhost/ReportServer.



  • I created a Report using Business Intelligence Studio. Its working working well, i can able to view records. But when i try to deploy the report an error occurs specifying that "A connection could not be made to the report server http://localhost/ReportServer. (Microsoft Report Designer)".
  • I open the IIS 7 and find out virtual directories "Reports" and "ReportServer" are available.
  • I check on the browser and type "http://localhost/reports".  I find the browser direct to this url: http://localhost/reports/Pages/Folder.aspx and find error specifying the following one:

         Error:The report server is not responding. Verify that the report server is running and can be accessed from this computer.

  • when i type http://localhost/reportmanager, i found the error:

    HTTP Error 404.0 - Not Found

    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.


Cannot redirect HTTP headers already sent


I have been working on an registeration page for my web site in asp.net.After the person succesfully registers , another page is called which sends an email.After the email is sent it should redirect to the default page . I came accross this error when trying to redirect after sending the email.

"Cannot redirect HTTP headers already sent"

.What could the problem be?

Here is the code

//send email
MailMessage mail = new MailMessage();
mail.To =strName ;
mail.From = "GiftWorld@yahoo.com";
mail.BodyFormat = MailFormat.Text;
mail.Subject = "Thank you for registering -Gift World.com";
mail.Body = "Thank you for registering -Gift World.com";
SmtpMail.SmtpServer = "mara.strathmore.edu" ;

WFE is out of synch? HTTP/1.1 200 OK Server: Microsoft


Encountering a strange situation here.... a little background.

We have 3 nodes.

Two servers are dedicated WFE's. Node 1 & Node 3. They are load balanced with a CSS.

One server is a dedicated indexer/crawler. Node 2.

We recently moved our database from a single server to a SQL cluster. We used the SQL Aliasing method as outlined here:


Everything works great, EXCEPT node3 seems to be out of synch. All existing sites are operating as expected. However, any new site collections I create only function on node1. If you hit node3 you recieve the following:

     HTTP/1.1 200 OK Server: Microsoft-IIS/7.0 Date: Fri, 27 Aug 2010 15:14:17 GMT Connection: close

It's like the site doesn't exist on node3. It doesn't matter if a new site collection is created in a new contentdb or an existing contentdb, it doesn't work on node3. On node1, new site collections are displayed as expected.

Here is what I have tried:

an IISreset on node3.
Initiated a full index.
Manually initiated a sync via stsadm
stsadm -listolddatabases is not listing any orphaned GUIds.
created a new contentdb.
flushed the c

How to Add Custom SOAP Headers Into The Server Response Message in WSE3.0?

Hi Dear All, Assuming I am the service provider, may i know how many ways are there to insert a custom header into the server response message? So far I tried several ways, and it can be done in custom SoapFilters (by playing with SOAPEnvelope object), and SoapExtension (SOAPMessage object). Just wondering if this could be done at web service class by specifying a SOAPHeader attribute, just like adding a SOAPHeader into the SOAP request message at consumer side? If can, it might be much smarter than SoapFilter and SoapExtension.   Thanks in advance!   Best Regards, Charles

HTTP Error 500.19 - Internal Server Error after SharePoint 2010 In-place upgrade

Hello We have done an SharePoint 2010 In-Place Upgrade. After the upgrade, we can access the Central Administration page without problems. However, when accessing the standard http port 80 site, the following error appears: Error Summary HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.   <fieldset><legend>Detailed Error Information</legend> Module IIS Web Core Notification Unknown Handler Not yet determined Error Code 0x80070032 Config Error The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration Config File \\?\C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config Requested URL http://coolsharepoint:80/ Physical Path   Logon Method Not yet determined Logon User Not yet determined </fieldset> <fieldset><legend>Config Source</legend> 534: </location> 535: <system.web.extensions> 536: <scripting> </fieldset>

How to pass values using http header to another domain?

Hi,There are two applications "Sender", "Receiver"."Receiver" is a asp.net page, running in a server"Sender" is not an asp.net page and running in some other server."Sender" is passing a string (eg. userName) through http header."Receiver" is reading the string from http header as follows        Request.Header["userName"].How to pass values through http header? Can I have some samples?Thanks,Ashokan

Sql Server 2005 ( remove header information from query output file "Job 'bustd_Daily_Query_Output_1

Dear All,I have scheduled job for querying output & asve it into particuler folder....but in the top of file i getting the message like "Job 'bustd_Daily_Query_Output_13July09' : Step 1, 'Query1' : Began Executing 2009-07-13 16:32:06"I want to remove this & want output in txt file format without above header....RegardsRavendra Cindia

WCF Basic Http Binding - Two server requests per method call

We have a service that uses BasicHttpBinding/Transport Security/Windows Authentication and is hosted in IIS. I have created a unit-test application in VSTS and whenever we test a WCF method, Fiddler records two calls. 1st call - No authorization token is sent. The WCF service returns a 401 error - Unauthorized: Access is denied. Http headers as sent in the request given below. POST http://localhost/AccountScreen.svc HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: "IAccountScreen/RetrieveAccountDetails" Host: localhost Content-Length: 243 Expect: 100-continue Connection: Keep-Alive 2nd call - Authorization token is sent and the WCF service returns the expected response. POST http://localhost/AccountScreen.svc HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: "IAccountScreen/RetrieveAccountDetails" Authorization: Negotiate Host: localhost Content-Length: 243 Expect: 100-continue I am not able to figure out why there are two calls made to the server in the first place and what is the significance of the first call. Any thoughts?

Programatically remove IIS HTTP headers

Our IIS server (v7) has the following settings in its custome HTTP headers for the whole site: Pragma: no-cacheCache-Control: private, no-cache, no-store, max-age=0, must-revalidate, post-check=0, pre-check=0X-Powered-By: ASP.NET Out of the whole site there are some pages require to remove the "no cache" setting to work properly. This is done manually by IIS Administrator before. Now we were told that we need to do it from code on our end. The following code were applied but no luck in success. Please advise! Thanks! Response.Headers.Remove("Pragma")Response.Headers.Remove("Cache-Control")Response.Headers.Add("Cache-Control")Response.CacheControl = "System.Web.HttpCacheability.Public"

Programmatically remove IIS HTTP header settings

 Our IIS server (v7) has the following settings in [Custom HTTP Headers] for our whole site: Pragma: no-cacheCache-Control: private, no-cache, no-store, max-age=0, must-revalidate, post-check=0, pre-check=0X-Powered-By: ASP.NET Out of the whole site, there are some pages that require the "no cache" setting to be removed for them to work properly. This was done manually by our IIS Administrator until recently.  Now we were told that we need to do it programmatically on our end. The following were the code snippets (VB.NET) we have used with no luck in success. Advice is appreciated, Thanks! Method-1Response.Headers.Remove("Pragma")Response.Headers.Remove("Cache-Control")Response.Headers.Add("Cache-Control", "private")Response.CacheControl = System.Web.HttpCacheability.public Method-2Response.ClearHeaders()Response.Headers.Clear()Response.CacheControl = "Public"Response.Cache.SetCacheability(HttpCacheability.Public)Response.Cache.SetAllowResponseInBrowserHistory(True)

MS Message Queueing 4.0 HTTP Support - 500 Internal Server Error

Hi all,   I've been trying to set up MSMQ 4.0 with HTTP Support to allow one of our partners to send messages to us. However, whenever I make any call to the msmq page I get an internal server error 500 (See below). My platform is Windows 2008 SE (64-bit) running as a DC (though MSMQ is running in workgroup mode).   Any hints on what might be causing this or how I can investigate further? Are there any log files for the ISAPI extension, or the MQISE.dll, or the MSMQ service that might help me shed light on this problem?   I've seen blogs about an issue with MSMQ 3.0 where the machine name can't be 15 characters long, is this still the case with MSMQ 4.0?   The error details are as below,     Server Error in Application "WWW.MYDOMAIN.COM/MSMQ" Internet Information Services 7.0 HTTP Error 500.0 - Internal Server Error There is a problem with the resource you are looking for, so it cannot be displayed. Detailed Error Information  Module IsapiModule Notification ExecuteRequestHandler Handler AboMapperCustom-113521 Error Code 0x8007007e Requested URL http://www.mydomain.com:80/msmq Physical Path c:\inetpub\www.mydomain.com\msmq Logon Method Anonymous Logon User Anonymous The path to the ISAPI Filter is incorrect. IIS received the request; however, an internal error occurred during the processing

after restoring content database getting error (HTTP/1.1 200 OK Server: Microsoft-IIS/7.5 Date: Tue,

Hi All, Problem i have taken backup of Old site content database procedure see below 1) first i changed the database to read only mode (Opened SQL Server2005-->selected DB--> properties--> Option-->Database Read-Only=True) 2) taken backup of database from the task--Backup(new.bak) 3) Copied the taken backup to new server and restored (Opened SQL Server2005 --> Right Click on Database Folder--> Restore Dataase) In To database: ihave given DB name From Device: i have selected database from the location where i have saved. click ok.  It has restored successfully 4) I have created a new webapplication and removed its content database from central admin. 5) with the help of stsadm command i restored the above db to this webapplication. then iam getting below error: HTTP/1.1 404 Connection: close Date: Tue, 14 Sep 2010 06:20:08 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET MicrosoftSharePointTeamServices: i have refered the below url for restoring http://metahat.blogspot.com/2008/11/backup-restoring-sharepoint-2007-site.html Please help. Thanks in advance.

Reporting Services 2008 - Repeating Headers when Headers are in a rectangle in header cell

Hello,I had the same problem as others where the tablix header will not repeat on multiple pages of the report.  I followed the instructions here http://blogs.msdn.com/robertbruckner/archive/2008/10/13/Repeat-Header-And-Visible-Fixed-Header-Table.aspx and it did not solve the problem.  After trying several scenarios, I found that it was not repeating because I have each header value in a rectangle which spans one column, rather than having each header value in it's own tablix column.For instance, if we have fields CompanyID and CompanyName on the report, the repeating headers work if I have them in separate columns like this:                              Tablix Column 1  |  Tablix Column 2Tablix Header row    Company ID        |  CompanyNameTablix Detail row      [CompanyID]      |  [CompanyName]It DOES NOT work when it is designed like this:                             Tablix Column 1Tablix Header Row   Company ID    Company Name  (tw

Is it possible to access an Analysis Server with Excel via http?

Hi, in our scenario we want to give another company access to out analysis server via web, their front end should be Excel. So first of all I made a setup like descriped here http://technet.microsoft.com/de-de/library/cc917711(en-us).aspx (but I have really no idea how to test it in an easy way because using MDX sample application ends up every time in "The connection either timed out or was lost.") But apart of that, is it possible to access an analysis server with Excel via http? I did not found any possibility to use a http-adresse in Excel as server path. Any ideas? Thanks and regards Peter  

WCF HTTP POST - The remote server returned an error: (400) Bad Request. - URGENT

client & sever code below-------------------------------------------- [ServiceContract(Namespace = "http://test.mydomain.com")] public interface IMyService{[WebInvoke(UriTemplate = "", BodyStyle = WebMessageBodyStyle.Bare, Method = "POST")] Stream SaveXML(Stream input); } ----------------------[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(Namespace = "http://test.mydomain.com")] public class MyService : IMyService{  public Stream SaveXML(Stream input)   {              StreamReader streamReader = new StreamReader(input);       string rawString = streamReader.ReadToEnd();       streamReader.Dispose();        // here need to save the input stream to xml format file          //       Encoding encoding = Encoding.GetEncoding("ISO-8859-1");       WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";         byte[] returnBytes = encoding.GetBytes(rawString);       return new MemoryStream(returnBytes);   } } --------------------------------------------------Client Code         string postData = GetXmlString("d:\\text.xml"); // user function        WebRequest request = WebRequest.Create("http://test.mydomain.com/myservice.svc");        request.Method = "POST";        byte[] byteArray = Encoding.UTF8.GetBytes(p

Advantage of Configuring HTTP Access to SQL Server 2008


I am Configuring HTTP Access to SQL Server 2008. I successfully did this.

Now my question is, What is the advantage of XMLA provider over MSOLAP analysis service provider??


Let us TRY this |

My Blog :: http://quest4gen.blogspot.com/
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend