November 2008 - Posts
Today I was looking for a solution how to detect when a client is a search engine crawler, you can create a fancy solution for this, but in the .NET framework their is already a solution to detect search engine crawler. The property Request.Browser.Crawler. If you use this property you always get false even if the site is visited by a search engine crawler, that's because it's not configured in a default installation of .NET.
ASP.NET uses the <browsercaps> section in machine.config or web.config to determine the client browser is a crawler or not. In the default installation the crawler filter information is all blank, that's why you'd always get false. To fix this problem, you should add the search engine crawler filters in the <browsercaps> and add this section to your web.config. Like this:
<configuration>
<!-- ...... -->
<system.web>
<browserCaps>
<filter>
<!-- Google Crawler -->
<case match="Googlebot">
browser=Googlebot
crawler=true
</case>
<!-- Yahoo Crawler -->
<case match="http\:\/\/help.yahoo.com\/help\/us\/ysearch\/slurp">
browser=YahooCrawler
crawler=true
</case>
<!-- MSN Crawler -->
<case match="msnbot">
browser=msnbot
crawler=true
</case>
<!-- check Alta Vista (Mercator) -->
<case match="Mercator">
browser=AltaVista
crawler=true
</case>
<!-- check Slurp (Yahoo uses this as well) -->
<case match="Slurp">
browser=Slurp
crawler=true
</case>
<!-- Baidu Crawler -->
<case match="Baiduspider">
browser=Baiduspider
crawler=true
</case>
<!-- check Excite -->
<case match="ArchitextSpider">
browser=Excite
crawler=true
</case>
<!-- Lycos -->
<case match="Lycos_Spider">
browser=Lycos
crawler=true
</case>
<!-- Ask Jeeves -->
<case match="Ask Jeeves">
browser=AskJeaves
crawler=true
</case>
<!-- IBM Research Web Crawler -->
<case match="http\:\/\/www\.almaden.ibm.com\/cs\/crawler">
browser=IBMResearchWebCrawler
crawler=true
</case>
</filter>
</browserCaps>
</system.web>
</configuration>
Tip: you can find more crawler info in your IIS logs ([Windows Folder]\system32\LogFiles)
From
Microsoft has
released a new cool charting control. It comes with documentations, samples and a lot of features, features like:
- All supported chart types.
- Data series, chart areas, axes, legends, labels, titles, and more.
- Data Binding
- Data manipulation, such as copying, splitting, merging, alignment, grouping, sorting, searching, filtering, and more.
- Statistical formulas and financial formulas.
- Advanced chart appearance, such as 3D, anti-aliasing, lighting, perspective, and more.
- Chart rendering.
- Events and Customizations.
- Interactivity and AJAX.
Below some pictures of sample charts:

More information:
If you have a querystring from for example the Uri class (Uri.Query) and you want to parse it so you can get al the params and values, instead of doing al lot of string manipulation you can use a very handy utility class, the HttpUtility. The HttpUtility class has a method ParseQueryString, this method parse a query string into a namevaluecollection. Like this:
string querystring = "?var1=test&var2=test2"
NameValueCollection nvColl = HttpUtility.ParseQueryString(querystring);
string var1 = nvColl["var1"];
string var2 = nvColl["var2"];
The string "var1" contains "test" and the "var2" contains "test2".
A few week I mentioned how to get intellisense for jQuery. Now the visual studio web tools team released a hotfix so the intellisense files will be found automatically if they have the same name as the orginal js file and the suffix "-vsdoc.js" more info can be found on the Visual Studio Web Tools team blog
Today I searched for a solution to parse a html string with ASP.NET controls on runtime. A string like for example this:
<table>
<tr>
<td>Name</td>
</tr>
<tr>
<td><asp:TextBox id="name" runat="server" /></td>
</tr>
</table>
Now I want to parse this string a runtime into a Control object, this can be done with the
ParseControl method from the
TemplateControl class, the ParseControl methods can be accessed from the Page instance, like this for example:
string html = "<table><tr><td>Name</td></tr><tr><td><asp:TextBox id=\"name\" runat=\"server\" /></td></tr>b</table>"
Control ctrl = Page.ParseControl(html);
somePlaceHolder.Controls.Add(ctrl);
After the html has been parsed the control can be added to for example a placeholder.
Today I was playing around with my windows in Visual Studio to get them
in place exactly how want it,, but how do I save my window layout
settings? I found it on Sara Ford's weblog, simply close Visual Studio and the window layout will be saved.
When you mess-up your windows your can reset them by pressing "Window" -> "Reset Window Layout".
More Posts