-
Notifications
You must be signed in to change notification settings - Fork 10
Prerender Middleware for ASP.NET
This is an application level middleware solution for prerender. This can be used for both ASP.NET WebForm and MVC.
- .NET Framework 4.0
- Microsoft.Web.Infrastructure (>= 1.0.0)
Install-Package DotNetOpen.PrerenderModule
Configure PrerenderHttpModule in your ASP.NET or ASP.NET MVC project, there are two ways to configure:
-
Option 1: Use UsePrestartForPrenderModule app setting. Once UsePrestartForPrenderModule is true, it means we will use PreApplicationStartMethodAttribute to dynamically load the http module.
<add key="UsePrestartForPrenderModule" value="true" />
-
Option 2: Use Web.config to configure PrerenderHttpModule (set UsePrestartForPrenderModule = false), please make sure you use Integrated Mode for application pool.
<add key="UsePrestartForPrenderModule" value="false" />
- Add Configuration Section
<section name="prerender" type="DotNetOpen.PrerenderModule.Configuration.PrerenderConfigurationSection, DotNetOpen.PrerenderModule" />
- Add Configuration Element
<!--prerender settings-->
<!--CrawlerUserAgentPattern: "(google)|(bing)|(Slurp)|(DuckDuckBot)|(YandexBot)|(baiduspider)|(Sogou)|(Exabot)
|(ia_archiver)|(facebot)|(facebook)|(twitterbot)|(rogerbot)|(linkedinbot)|(embedly)|(quora)|(pinterest)|(slackbot)
|(redditbot)|(Applebot)|(WhatsApp)|(flipboard)|(tumblr)|(bitlybot)|(Discordbot)"-->
<!--WhiteListPattern, BlackListPattern: will check raw URL, which includes query string-->
<!--AdditionalExtensionPattern: will only check extension-->
<prerender ServiceUrl="http://localhost:3000"
Token=""
WhiteListPattern=""
BlackListPattern=""
AdditionalExtensionPattern=""
ProxyUrl=""
ProxyPort="80">
</prerender>
If you want to add your own CrawlerUserAgentPattern which is different from default, you can add an attribute on prerender element; Otherwise, don't add CrawlerUserAgentPattern attribute.
More configuration setting details, please go to Configuration & Check Priority
You can download the sample project from:
Test Page: ~/Home/About