by Keyvan Nayyeri via Keyvan Nayyeri on 8/7/2006 6:50:35 PM
One of cool features in ASP.NET is HttpCapabilitiesBase class. This class contains tons of common properties to give back several useful information about client browser to web developers.
It can be more than what it seems to be when you can generate different content for search engines and avoid rendering some unnecessary data such as Ads and external links for them by using HttpRequest.Browser.Crawl Boolean property to have a better simpler index in search engines.
Look at my sample below. I've created two different Master Pages for web crawlers and normal visitors to add them to page dynamically. Here is the code:
protected void Page_PreInit(object sender, EventArgs e)
{
if (base.Request.Browser.Crawler)
GenerateContent(true);
else
GenerateContent(false);
}
private void GenerateContent(bool IsCrawl)
if (IsCrawl)
base.MasterPageFile =
"~/CrawlsMaster.master";
"~/NormalVisitorsMaster.master";
ContentPlaceHolder PlaceHolder =
base.Master.FindControl("ContentPlaceHolder1")
as ContentPlaceHolder;
if (PlaceHolder != null)
Label lblOutput =
PlaceHolder.FindControl("lblOutput")
as Label;
if (lblOutput != null)
lblOutput.Text = "Welcome Crawler";
lblOutput.Text = "Welcome Visitor";
Output for normal visitors:
Output for web crawlers:
Other useful application for this property can be in some situations that you want to block visitors and don't want to miss search engine crawlers. For example I can use it in my ClientBlocker HttpModule to let search engines visit site even their IPs are blocked.
Original Post: HttpRequest.Browser.Crawl Property
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.