Right now I am researching how to set maxage on network folder.
My test environment, there are 3 machines.
Machine A is to manage IIS Server remotely programmatically.
Machine B is windows 2008 R2 contained IIS Server, this IIS Server have a website "testMaxAge" , its physical path is network folder, like
\\15.12.12.2\sharefolder
the same source code, In machine A, I can set maxAge successfully if the website physical path is local folder.
This is because the settings will be stored in web.config file located in physical directory. You can grant the account NTFS permission on the network folder.
Or, store StaticContentSection in applicationhost.config file by using a <location/> element:
Set oSection = oWebAdmin.Get("StaticContentSection.Path=" & _ "'MACHINE/WEBROOT/APPHOST',Location='testMaxAge'") ;
appcmd.exe set config "testMaxAge" -section:system.webServer/staticContent /clientCache.cacheControlMaxAge:"02.01:01:46" -commit:apphost
Please mark the replies as answers if they help or unmark if not.
Feedback to us
Thanks very much for your help. This issue bother me a little of days. I have further question. If the website set maxAge on both web.config and applicationhost.config. and I know, right now the web.config will overwrite applicationhost.config. but what solution
is let applicationhost.config not be override by web.config .
Aadm zhu
6 Posts
How to programmatically set cacheControlMaxAge of clientCache on network folder ?
Jul 04, 2011 03:18 AM|LINK
Right now I am researching how to set maxage on network folder.
My test environment, there are 3 machines.
Machine A is to manage IIS Server remotely programmatically.
Machine B is windows 2008 R2 contained IIS Server, this IIS Server have a website "testMaxAge" , its physical path is network folder, like \\15.12.12.2\sharefolder
Machine C is the host of network folder.
-----------------------------------------------------------------------------------------------------------------
TestCase one:
In machine B, using IIS Management UI , I can successfully set this maxage into the network folder \\15.12.12.2\sharefolder.
In machine A, I call IIS WMI provider api, I can't set this maxage, get a error message, "Access is Denied"
the following is my code.
Set oSection = oWebAdmin.Get("StaticContentSection.Path=" & _ "'MACHINE/WEBROOT/APPHOST/testMaxAge',Location=''") ;
clientCache = oSection.Get("ClientCache");
clientCache.CacheControlMode=2;
clientCache.CacheControlMaxAge="00000001010101:000000:000";
oSection.put_();
the same source code, In machine A, I can set maxAge successfully if the website physical path is local folder.
-------------------------------------------------------------------------------------------------------------------
TestCase Two:
I use another way to set this maxage, is to appcmd tool.
In machine B, using the following command, I can successfully set maxage on network folder.
appcmd.exe set config "testMaxAge" -section:system.webServer/staticContent /clientCache.cacheControlMaxAge:"02.01:01:46"
In machin A, using COM api "Win32_Process", I call the same command above. I can't set the maxage , get error message, "Access is denied"
I would appreciate if your advise or comments.
-----------------------------------------------------------------------------------------------
The following is fragment of my applicationHost.config
<site name="testMaxAge" id="3">
<application path="/">
<virtualDirectory path="/" physicalPath="\\15.12.12.2\sharefolder"
userName="CORP\otesting"
password="[enc:AesProvider:J8Nm8/zvod5DAS1q739W1vldCC+ABsrMERw6BMGHP9s=:enc]"/>
</application>
<bindings>
<binding protocol="HTTP" bindingInformation="*:80:jianhua.dev.corp.beaumaris.net" />
</bindings>
</site>
Leo Tang - M...
4161 Posts
Microsoft
Re: How to programmatically set cacheControlMaxAge of clientCache on network folder ?
Jul 07, 2011 08:45 AM|LINK
Hi,
This is because the settings will be stored in web.config file located in physical directory. You can grant the account NTFS permission on the network folder.
Or, store StaticContentSection in applicationhost.config file by using a <location/> element:
Set oSection = oWebAdmin.Get("StaticContentSection.Path=" & _ "'MACHINE/WEBROOT/APPHOST',Location='testMaxAge'") ;
appcmd.exe set config "testMaxAge" -section:system.webServer/staticContent /clientCache.cacheControlMaxAge:"02.01:01:46" -commit:apphost
Feedback to us
Develop and promote your apps in Windows Store
Aadm zhu
6 Posts
Re: How to programmatically set cacheControlMaxAge of clientCache on network folder ?
Jul 07, 2011 03:47 PM|LINK