How to read a section from web.config on IIS7 w/ .net 4 in C# -
i've got following section in web.config:
<system.webserver> <staticcontent> <clientcache cachecontrolmode="usemaxage" cachecontrolmaxage="0.00:00:30" /> <remove fileextension=".ogv" /> <mimemap fileextension=".ogv" mimetype="video/ogg" /> <remove fileextension=".webm" /> <mimemap fileextension=".webm" mimetype="video/webm" /> <!-- , bunch more... --> </staticcontent> <!-- ... --> </system.webserver>
here's i'm trying in psuedo-code:
var ext = ".ogg"; var staticcontentelements = getwebconfig().getsection("system.webserver/staticcontent").childelements; var mimemap = staticcontentelements.where(c => c.getattributevalue("fileextension") != null && c.getattributevalue("fileextension").tostring() == ext ).single(); var mimetype = mimemap.getattributevalue("mimetype").tostring();
basically, need search mimemaps fileextension , mimetype.
you need create custom configuration section information.
Comments
Post a Comment