Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
MiniBlog web.config as virtual application
<add key="blog:path" value="myblog"/>
<handlers>
<remove name="CommentHandler"/>
<add name="CommentHandler" verb="*" type="CommentHandler" path="/myblog/comment.ashx"/>
<remove name="PostHandler"/>
<add name="PostHandler" verb="POST" type="PostHandler" path="/myblog/post.ashx"/>
<remove name="MetaWebLogHandler"/>
<add name="MetaWebLogHandler" verb="POST,GET" type="MetaWeblogHandler" path="/myblog/metaweblog"/>
<remove name="FeedHandler"/>
<add name="FeedHandler" verb="GET" type="FeedHandler" path="/myblog/feed/*"/>
<remove name="CssHandler"/>
<add name="CssHandler" verb="GET" type="MinifyHandler" path="/myblog*.css"/>
<remove name="JsHandler"/>
<add name="JsHandler" verb="GET" type="MinifyHandler" path="/myblog*.js"/>
</handlers>
<httpErrors>
<remove statusCode="404"/>
<error statusCode="404" responseMode="ExecuteURL" path="/myblog/404.cshtml"/>
</httpErrors>
<location path="." inheritInChildApplications="false">
<system.web>
...
</system.web>
<system.webServer>
...
</system.webServer>
</location>
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="blog:theme" value="OneColumn"/>
<add key="blog:name" value="MiniBlog"/>
<add key="blog:description" value="I write about web development in ASP.NET and Visual Studio"/>
<add key="blog:image" value="https://github.global.ssl.fastly.net/images/modules/logos_page/Octocat.png"/>
<add key="blog:postsPerPage" value="5"/>
<add key="blog:daysToComment" value="999"/>
<add key="blog:moderateComments" value="true"/>
<add key="blog:email" value="mail@example.com"/>
<add key="blog:path" value="myblog"/>
<add key="blog:cdnUrl" value=""/> <!-- Converts all image, js and css references to absolute urls. Example: value="http://static.mydomain.com" -->
<add key="PreserveLoginUrl" value="true"/>
<add key="webpages:Enabled" value="true" />
<add key="webpages:Version" value="3.0.0.0" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5" enableVersionHeader="false" requestValidationMode="2.0"/>
<pages validateRequest="false"/>
<customErrors mode="RemoteOnly" defaultRedirect="~/">
<error statusCode="404" redirect="~/404/"/>
</customErrors>
<authentication mode="Forms">
<forms defaultUrl="~/" loginUrl="~/views/login.cshtml" name="miniblog" timeout="10080">
<credentials passwordFormat="SHA1">
<!-- Password is "demo". Generate your hash password here http://www.stringfunction.com/sha1-hash.html -->
<user name="demo" password="89e495e7941cf9e40e6980d14a16bf023ccd4c91"/>
</credentials>
</forms>
</authentication>
<machineKey decryption="AES" validation="SHA1" decryptionKey="435D9CC99471D1E7C70FFEBA5EC71F28048BF9016605B82CC69B091FD317B294" validationKey="25C5D98CE093E77C2F886A6D8C6DA8FBC77CD764A1BF49E5D30CD123C5E19553"/>
</system.web>
<system.net>
<mailSettings>
<!-- This example uses Hotmail/Outlook.com. Just modify the username and password -->
<smtp>
<network enableSsl="true"
host="smtp.live.com"
port="587"
userName="example@outlook.com"
password="1234abcd"/>
</smtp>
</mailSettings>
</system.net>
<system.webServer>
<urlCompression doDynamicCompression="true" doStaticCompression="true"/>
<modules runAllManagedModulesForAllRequests="false">
<!-- Remove this to disable HTML minification-->
<add name="WhitespaceModule" type="WhitespaceModule" preCondition="managedHandler" />
</modules>
<handlers>
<remove name="CommentHandler"/>
<add name="CommentHandler" verb="*" type="CommentHandler" path="/myblog/comment.ashx"/>
<remove name="PostHandler"/>
<add name="PostHandler" verb="POST" type="PostHandler" path="/myblog/post.ashx"/>
<remove name="MetaWebLogHandler"/>
<add name="MetaWebLogHandler" verb="POST,GET" type="MetaWeblogHandler" path="/myblog/metaweblog"/>
<remove name="FeedHandler"/>
<add name="FeedHandler" verb="GET" type="FeedHandler" path="/myblog/feed/*"/>
<remove name="CssHandler"/>
<add name="CssHandler" verb="GET" type="MinifyHandler" path="/myblog*.css"/>
<remove name="JsHandler"/>
<add name="JsHandler" verb="GET" type="MinifyHandler" path="/myblog*.js"/>
</handlers>
<httpErrors>
<remove statusCode="404"/>
<error statusCode="404" responseMode="ExecuteURL" path="/myblog/404.cshtml"/>
</httpErrors>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365:00:00"/>
</staticContent>
<security>
<requestFiltering allowDoubleEscaping="true">
<fileExtensions>
<remove fileExtension=".cshtml"/>
<add fileExtension=".cshtml" allowed="true"/>
</fileExtensions>
</requestFiltering>
</security>
<httpProtocol>
<customHeaders>
<remove name="x-powered-by"/>
<add name="Content-Security-Policy" value="object-src 'none';"/>
<add name="Arr-Disable-Session-Affinity" value="True" />
</customHeaders>
</httpProtocol>
<defaultDocument>
<files>
<remove value="index.cshtml"/>
<add value="index.cshtml"/>
</files>
</defaultDocument>
<rewrite>
<rules>
<clear />
<rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{CACHE_URL}" pattern="*://www.*" />
</conditions>
<action type="Redirect" url="{C:1}://{C:2}" redirectType="Permanent" />
</rule>
<rule name="ProtectStorageXml" stopProcessing="true">
<match url="posts/(.*)\.xml" />
<action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
</rule>
<rule name="BlogEngine slug" stopProcessing="true">
<match url="^post/(.*)\.aspx" ignoreCase="true"/>
<action type="Redirect" redirectType="Permanent" url="/post/{R:1}"/>
</rule>
<rule name="slug" stopProcessing="true">
<match url="^post/(.*)" ignoreCase="true"/>
<action type="Rewrite" url="?slug={R:1}"/>
</rule>
<rule name="paging" stopProcessing="true">
<match url="^(page/)([\d]{0,})" ignoreCase="true"/>
<action type="Rewrite" url="?page={R:2}"/>
</rule>
<rule name="category" stopProcessing="true">
<match url="^category/([^/]+)(/page/)?([\d]+)?" ignoreCase="true"/>
<action type="Rewrite" url="?category={R:1}&amp;page={R:3}"/>
</rule>
<rule name="robots.txt" stopProcessing="true">
<match url="robots.txt"/>
<action type="Rewrite" url="views/robots/robots.cshtml"/>
</rule>
<rule name="sitemap" stopProcessing="true">
<match url="sitemap.xml"/>
<action type="Rewrite" url="views/robots/sitemap.cshtml"/>
</rule>
<rule name="fingerprint" stopProcessing="true">
<match url="(.+)(_([0-9]{18})+\.)([\S]+)"/>
<action type="Rewrite" url="{R:1}.{R:4}"/>
</rule>
</rules>
<outboundRules>
<clear />
<rule name="Remove ETag">
<match serverVariable="RESPONSE_ETag" pattern=".+"/>
<action type="Rewrite" value=""/>
</rule>
<rule name="Send correct Vary">
<match serverVariable="RESPONSE_Vary" pattern=".+"/>
<action type="Rewrite" value="Accept-Encoding, If-Modified-Since"/>
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment