Reputation: 10824
A while ago I designed a app that would insert a meta tag into my pages so I could test them with internet explorer in different document modes. My solution, though functional, was klugy. Assuming IIS7 and explorer as server/client, what are some light weight solutions for quickly adding a meta tag programmaticly for a short time.
Upvotes: 1
Views: 535
Reputation: 13581
You can do that very easily using URL Rewrite and leverage the Outbound Rewrite capabilities. Once it is installed just add a web.config to the application folder like the following and it will automatically insert a META tag to every HTML page that is served by the application. You can obviously add more conditions and make that only rewrite for pages you want (see preConditions) as well as capture data from headers or other places and add it in the response.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<outboundRules rewriteBeforeCache="true">
<rule name="WriteMETA" preCondition="MatchHTML">
<match pattern="<head>" occurrences="1" />
<action type="Rewrite" value="<head>
<meta name='author' content='Carlos Aguilar Mares' />
" />
</rule>
<preConditions>
<preCondition name="MatchHTML" patternSyntax="Wildcard">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Upvotes: 1