Something is forcing responses to have cache-control: private in IIS7 - iis-7

I have this in my web.config:
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="Cache-Control" value="max-age=30,public" />
</customHeaders>
</httpProtocol>
</system.webServer>
But when I load the page, this is the response header:
Cache-Control: private,max-age=30,public
It is an ASP.NET MVC application, the controller has no cache directives specified anywhere.

try this
<system.web>
<httpRuntime sendCacheControlHeader="false" />
</system.web>
Let us know how it goes.
Jason

Related

Removing Server tag in Header of IIS10

I am asking this question here because every other trick in the book from various sites including microsofts has failed to fix this for me.
I have added
<security>
<requestFiltering removeServerHeader="true" />
</security>
in <system.webserver>
Then i also added
<system.web>
<httpRuntime enableVersionHeader="false"/>
</system.web>
also added
<httpProtocol>
<customHeaders>
<clear />
</customHeaders>
</httpProtocol>
However none of this seems to remove the "Server" header from the response.
Any idea as to what else i can try other than URlRewrite or outboundrule??

I have an error when loading wordpress site

I have this site but the css files do not seem to load correctly :http://185.58.193.198:12500/HelpDesk/
Can some tell me what changes i should make. I have used wamp for the database and IIS for hosting
There many reasons for 403 error, you can try to add below code in your web.config file:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
</customHeaders>
</httpProtocol>
</system.webServer>
and you can also try enabled anonymous authentication in iis authentication.

IIS Child application

Hosted Angular 2 project in IIS 8.5 server. And I want to use my Asp.net project in same port like child application. So, I have created an application under my angular website and pointed it to Asp.net application folder, I gave permissions too.
http://localhost/api (api is alias name for Asp.net project) but not able to accss http://localhost/api/mycontroller/method.
In Asp.net webconfig what are the changed I have to do?
Added inheritInChildApplications in config file,but no use
<location path="." inheritInChildApplications="false">
<system.web>
In angular web.config
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type, Authorization, X-Requested-With" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
and in Asp.net webconfig
<location path="." inheritInChildApplications="false"><system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept, Authorization,*" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
So am getting Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Access-Control-Allow-Origin' error.

Disabling Output caching through web.config

I am trying to neatly disable output caching for WCF application. enableOutputCache attribute does not work for some reason, can someone explain the reason, or suggest a work around.
<system.web>
<caching>
<outputCache enableOutputCache="false" enableFragmentCache="false"></outputCache>
<outputCacheSettings>
<outputCacheProfiles>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
Thanks
I know this is an old question but I'd like to give my two cents. I actually needed to disable caching of webapi services that are called by a SPA, and on some versions of IE they where cached by default unless the cache-control:no-cache and similar headers where present. What I did to enable browser caching of static resources and disable it for all the services was add the headers depending on the location using the web-config.
i.e.
<location path="api">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache" />
<add name="Expires" value="-1" />
<add name="Pragma" value="no-cache" />
</customHeaders>
</httpProtocol>
</system.webServer>

Overwrite web.config setting

Environment: IIS 7, .Net 4.0
In web.config of our application, it has this section:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="cache-control" value="no-cache" />
</customHeaders>
</httpProtocol>
</system.webServer>
Most of our application requires no-cache, but there is only one page that requires cache-control to be Private. Is a way to do it?
Appreciated for any input
You cannot apply or override settings from web.config to a particular page, however you can do this for all pages inside a folder, by following settings.
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="cache-control" />
<add name="cache-control" value="no-cache" />
</customHeaders>
</httpProtocol>
</system.webServer>
However, you can override the cache-control settings in Page_Load event of a particular page.
Response.CacheControl = "Private";
You can also change response caching for a page by setting the location attribute of #outputcache directive.
<%# OutputCache Location="Server" %>

Resources