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

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

Programmatically remove IIS HTTP header settings

Posted By:      Posted Date: September 11, 2010    Points: 0   Category :ASP.Net
 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)

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



Programmatically Hide Master Pages from Site Master Page Settings page?



I know there is a field you can check when you edit the properties of a Master Page in the Master Page Gallery to set a Master Page to hidden but ... can anyone think of a way to programmatically hide specific Master Pages from the Site Master Page Settings page?

Maybe this should be two questions:

  1. How do I programmatically access a Master Page in a Master Page Gallery?
  2. Is there a property that can be set that will hide the page from the Site Master Page Settings page?

Setting language settings programmatically MUI?!

Is it possible to set the language settings programmatically ?? Site settings > site administration > language settings and next programmatically select the installed language packs?

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

Server cannot append header after HTTP headers have been sent

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  

Remove Empty Listview Header

Can any one help me to remove the empty header generated at the end of a listview . i am using it to display a gridview of rows.

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"

How to remove 'Delete Item' from context menu of a programmatically created list?

How to remove 'Delete Item' from context menu of a programmatically created list?
I have document library which is created programmatically but now I don't want to have 'Delete Item' in context menu of that document library. Are there any possibilites?

WSE 2.0 and/or WCF - how to set wsa:Action in soap:Header different from HTTP header SoapAction?


I currently have a WSE 2.0 WebServicesClientProtocol object (generated from WSDL) created which has a a valid uri as its soapAction (from the WSDL binding). I need to set the <wsa:Action> value in the <soap:Header> to something other than the binding's soapAction. I know this violates W3C protocol, but the web services are another party's and cannot be changed.

I code (where "transport" is the WebServicesClientProtocol object) :

transport.RequestSoapContext.Addressing.Action = new Microsoft.Web.Services2.Addressing.Action(reqAction);

and can see in the VS debugger that it sets the action, but when I call the method to send the web request the <wsa:Action> is reset to the same value as the soapAction in the HTTP header. I assume WSE 2.0 is doing this. Can a custom SoapOutputFilter help me to "manually override" the <wsa:Action>?

If I abandon WSE 2.0 (which I kno

How programmatically change Additional Column Settings - Show field?


Hello. I use the SPFieldUser in my list. I can change Additional Column Settings - Show field: "Name with Presense" on the "Name (with Picture and details)" using the WSS Web interface. How do it programmatically, using Object Model WSS?

Cant reuse Http connections. No KeepAlive header. HttpWebRequest.KeepAlive = true;


I tried to reuse Http connections setting KeepAlive but it simply doesnt work. I looked in the Http messages using Feedler and Charles but all I can see is Connection: close in response. I am sure I use HTTP 1.1 as it says so in the request.

I see 600 TCP connections in wait state opened by 10 threads. Each thread run one http request at a time.

There is also bunch of responses which say - the unauthenticated request. The service requires digest authentication. Why some requestes fail to be authenticated?? 

P.S. I just found this thread: http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/87bc7029-ce23-438a-a767-f7c32dcc63a7 and I tried to set UnsafeAuthenticatedConnectionSharing = true but still my TCP connections are not reused.

    static void GetRest(string rest) 

Programmatically changing the 'Activities I am following' under Newsfeed Settings

Hi, is it possible to programatically select/deselect activities I am following on the news feed preferences page under MySites? I want to be able switch on/off notifications for both custom events and those provided by Sharepoint 2010 out-of-the-box.

read http custom header from web service


cant read http custome header "MSISDN" from my web service ... same code works on regular asp.net page. Can anyone shade a light on that subject ?

Is it possible to remove 'SharePoint Designer Settings' link from Site collection Adminitration Se

Is it possible to remove the link 'SharePoint Designer Settings' from the Site Collection Administration section of settings page.

Programmatically remove link from lookup field

I've found this link describing an approach to remove the link from a lookup field via javascript. Is there an other way except adding a content editor webpart to every site with lookup fields? Like setting a property for the lookup field? Thanks

remove Column header from List View Webpart


hi, i am having sharepoint 2010 Enterprise RTM trial on Windows server 2008 SP2. I wanted to know how a column header of a list in List View Webpart can be hide ?

i have tried the following article:


but i don't see any source editor in content Editor Weppart and also the Hidden button is disabled....

Is it necessary to do this task from code ?

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