by
Roland Schumacher alias GENiALi
21. März 2010 -- 475
words -- 0 mal gelesen
klaus_b@.NET has recently discussed a lot of improvements to the BlogEngine.NET on his blog and also code. Since I use also BlogEngine.NET and own screw this made me naturally small. Once it was about XML-RPC API that are not correctly implemented and once to use the robots meta tag. And I found quite fascinating with the meta tag. I wanted to incorporate that necessarily.
In regard to "Earn money" with the blog makes the statement certainly sense. And I'll test this. I want not the pages or the archive in the index of the search engines have but the posts. So it looks like this can be controlled with the meta tag robots.
However I wanted to have to adjust only one file and not each of which is to be any how specifically controlled. First, I was thinking about an extension for BlogEngine.NET. However there are on event no meaningful that it could react. Once a page has been opened, which has nothing to do with posts, the Post.Serving event is raised no longer. There is still a Page.Serving event. Page is the base class of BlogEngine.NET. Unfortunately, the implementation of Page.Serving is a corpse. The event is never raised. What a pity.
So, what does each theme by BlogEngine.NET as the basis? The site.master. It is always called. No matter what is opened. Thus this can be handled nicely centrally with the meta tag at one point.
I have lot of code from the klaus_b @.NET solution taken.
protected void Page_Load (object sender, EventArgs e)
{
SetRobotsMetaTag(sender);
}
private void SetRobotsMetaTag (object sender)
{(
page page ((MasterPage) = sender).}Page;
String [] noindexPages = new [] {"default.aspx", "archive.aspx", "contact.aspx", "search.aspx"};
//Per to default everything indexed and tracked to.
string metaContent = "index, follow";
foreach (string noindex in noindexPages)
{
if (page.)}Request.Path.ToLower().IndexOf(noindex) > - 1)
{
//Es are but exceptions which are not indexert.
}metaContent = "noindex, follow";
break;
}
}
HtmlMeta day = null;
foreach (control control in page.)(Header.Controls)
{
if (control is HtmlMeta
& & ((HtmlMeta)ctrl).)}(Name.ToLowerInvariant() == "robots")
{
tag = (HtmlMeta) control;
}tag.Content = metaContent;
break;
}
}
If (tag == null)
{
var meta = new HtmlMeta();
}meta.Name = "robots";
meta.Content = metaContent;
page.{{Header.Controls.Add(meta);
}
}The pages are defined on line 10 should not be indexed. All others are indexed and tracked.
Define new sites you may be collected centrally.
What is important, not the one that robots meta-tag more than once in the code. In the settings of the blog information may be collected in the HTML head section that are displayed in the header of the HTML. I use this lively for various meta tags. There would have to be removed robots meta tag. Otherwise it comes more than once in the HTML code. What then makes a bot that is not clear to me. He takes the first or the last? So just out.

611923a4-7dbf-4ee9-baa3-6ffa5583bfa8|0|.0
Tags: