开发者

What exactly does the staticcontent tag in the web.config file apply to?

I've been reading about the staticContent element in t开发者_开发技巧he web.config file but I'm having a bit of trouble figuring out exactly what ASP.Net considers static content. I assume it's going to include images, js files, css and static html files but I can't seem to find any articles that explicitly state this. Does anyone have links to documentation that explains this in detail?


I think this may be the information you're missing - Static Content MimeMap


Whilst this question is rather old and I expect Kiquenet got it sorted out none of the answers actually answer the question, I found this article looking for the answer, I expect others will to. This article answers the question:

IIS and Static content?

To paraphrase, static files are those IIS does not have a specific handler for. i.e. every file type listed in the .Net framework web.config section httpHandlers is NOT static.

Please look at Ben Swayne's most excellent answer, to quote:

You can inspect the list of file handlers in IIS by navigating to your website and then click 'Handler Mappings'. By default these are inherited from the .Net base web.config which is in a different location depending on your .Net framework version.

C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config

If a file being requested isn't already explicitly mapped to another handler it falls to a catch all handler (*) as the last option (System.Web.DefaultHttpHandler) which determines if it is a static file or a directory browsing request. So Static files are simply files not bound to another handler already.


As I understand it, the staticContent element in the web.config is where you can set how your site should cache it's static resource.

So as to your question of what kind of content can be specified here, it would be any file that you could benefit from caching, i.e. images, video, etc.

Also, just to provide some links I found useful:
How to configure static content cache per folder and extension in IIS7?
http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache


http://www.iis.net/configreference/system.webserver/staticcontent/mimemap says,

The <mimeMap> element of the <staticContent> element is included in the default installation of IIS 7.

IOW the list of 'static' file types is I suppose defined in the server's machine.config and/or overriden using web.config files.

You can select "Mime Types" in IIS Manager to view the list of MIME Types ... I see about 400 of these, from .323 and .aac through to .xslt and .zip, including .htm and .html but not including .aspx.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜