IIS Child application - asp.net

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.

Related

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.

Set caching on CSS files on IIS7 is not working

I am trying to implement the advice from Google's Pagespeed concerning browser caching(Set Expirer or Cache-control headers on static content).
After reading many posts here (like IIS7 Cache-Control ) and on other website I just can't seem to figure out why Pagespeed is for example still disapproving my CSS files.
For example: http://test.grotefeesten.nl/clientdata/71/js/jssor.config.js. This file has an expiration time of 1 day according to local PageSpeed but not according to the online PageSpeed test.
My web.config:
<caching>
<profiles>
<add extension=".css" policy="CacheUntilChange"
kernelCachePolicy="CacheUntilChange" location="Any" />
</profiles>
</caching>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="public" />
</customHeaders>
</httpProtocol>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlCustom="max-age"
cacheControlMaxAge="1.00:00:00" />
</staticContent>
Does anybody see what I am missing here to set the Expires header properly?
I had been struggling with this myself. However, I found a solution:
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="max-age=2592000" />
</customHeaders>
</httpProtocol>
This was all it took. The value in the code above, "max-age=2592000", is 1 month.

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>

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

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

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