Subscribe: Dr.NETjes
Added By: Feedage Forager Feedage Grade B rated
Language: English
add  aspx  code  current  log net  log  net  new  note  page  set  solr  string  system  text  user  web  webpart 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Dr.NETjes




Faceted search with Solr on Windows

Tue, 28 Dec 2010 23:12:00 GMT

With over 10 million hits a day, is probably the largest ASP.NET website which uses Solr on a Windows platform. While all our data (i.e. real estate properties) is stored in SQL Server, we're using Solr 1.4.1 to return the faceted search results as fast as we can. And yes, Solr is very fast. We did do some heavy stress testing on our Solr server, which allowed us to do over 1,000 req/sec on a single 64-bits Solr instance; and that's including converting search-url's to Solr http-queries and deserializing Solr's result-XML back to .NET objects! Let me tell you about faceted search and how to integrate Solr in a .NET/Windows environment. I'll bet it's easier than you think :-) What is faceted search? Faceted search is the clustering of search results into categories, allowing users to drill into search results. By showing the number of hits for each facet category, users can easily see how many results match that category. If you're still a bit confused, this example from CNET explains it all: The SQL solution for faceted search Our ("pre-Solr") solution for faceted search was done by adding a lot of redundant columns to our SQL tables and doing a COUNT(...) for each of those columns:   So if a user was searching for real estate properties in the city 'Amsterdam', our facet-query would be something like: SELECT COUNT(hasGarden), COUNT(yearBuilt1930_1940), COUNT(yearBuilt1941_1950), COUNT(etc...) FROM Houses WHERE city = 'Amsterdam' While this solution worked fine for a couple of years, it wasn't very easy for developers to add new facets. And also, performing COUNT's on all matched rows only performs well if you have a limited amount of rows in a table (i.e. less than a million rows). Enter Solr "Solr is an open source enterprise search server based on the Lucene Java search library, with XML/HTTP and JSON APIs, hit highlighting, faceted search, caching, replication, and a web administration interface." (quoted from Wikipedia's page on Solr) Solr isn't a database, it's more like a big index. Every time you upload data to Solr, it will analyze the data and create an inverted index from it (like the index-pages of a book). This way Solr can lookup data very quickly. To explain the inner workings of Solr is beyond the scope of this post, but if you want to learn more, please visit the Solr Wiki pages. Getting faceted search results from Solr is very easy; first let me show you how to send a http-query to Solr: http://localhost:8983/solr/select?q=city:Amsterdam This will return an XML document containing the search results (in this example only three houses in the city of Amsterdam):                              3203            Amsterdam            Keizersgracht            false            1932                            3205             Amsterdam             Vondelstraat             true            1938            &[...]

QuickBlog: Free VS2005 template for a weblog application

Fri, 10 Feb 2006 09:03:00 GMT

Inspired by Scott Guthrie's MyLists example webapplication, I've made a simple (but fully functional) weblogging application in Visual Studio 2005, which you can download here (all sources included).

Add this template to your VS2005 VWD ProjectTemplates folder (or just unzip it somewhere and open it with Visual Web Developer). The Visual Web Developer C#-ProjectTemplates folder is default located in \My Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual Web Developer\CSharp.

Note that I've created this weblog example-application in only 4 hours(!), and it contains not a single line of code.
Yep, that's right: 0 lines of code!!!  I accomplished this by using:

  • SQL2005 Database designer of VS.NET 2005 (no code)
  • TableAdapter Wizard to create typed datasets (no code)
  • ObjectDataSources using the typed datasets (no code)
  • GridView and DetailsView controls to create/read/update/delete postings and comments (no code)
  • FreeTextBox for richtext creation/editing of postings (no code)

Features of this QuickBlog webapplication:

  • Master- and Contentpages
  • Table-less design
  • Skinning en Theming
  • Creating and editing of Postings (by admin)
  • Readers can add Comments (admin can remove them)
  • Login control, Membership
  • A lot of GridViews and DetailsViews
  • RSS feed

Some screenshots:


Visitor writing a comment:

After logging on, the admin can manage postings and comments (or create a new posting):

MagicAjax.NET online demo's !!

Fri, 09 Dec 2005 11:02:00 GMT

So you want to use Ajax to make your webapplications more interactive and better performing, but you don't want the hassle of writing cross-browser JavaScript?
And you also want to keep using the ASP.NET server-side programming model?

Then open-source MagicAjax.NET is the right solution for you!

MagicAjax is easily integrated in your ASP.NET 1.1 and 2.0 webapplications:

  • Step 1: Add the MagicAjax HttpModule in your web.config
  • Step 2: You put the part of your page that you want to have Ajax functionality inside an AjaxPanel ()

That's all you need to do! The MagicAjax framework takes care all of the intrinsic details for you.

We've put together a few example pages to show the power of MagicAjax.NET. See the online demo on (note that the server is sometimes very slow):

You can view the sources of all demo pages online, so you can see for yourself how easy it is to use MagicAjax.
Tip: Also have a look at these MagicAjax demo's using FireFox. Fully supported!

Next you see a screenshot of the WebPart Framework in ASP.NET 2.0 using MagicAjax.NET.
Moving, adding and removing of WebParts is all done without a single visual postback; the WebParts just appear on your page!


Using Atlas to implement client-side Master-Detail dropdowns

Mon, 03 Oct 2005 20:51:00 GMT

After attending the PDC, I thought it would be cool to use Atlas for solving a common postback-overhead problem in ASP.NET : 2 connected Master-Detail dropdown lists.

Using plain ASP.NET 1.x, the way to implement this is by setting the 'AutoPostBack' property of the master dropdown to 'true' and then fill the detail dropdown after a postback. But we all know postbacks are slow and bad for user experience; a much better way to solve this problem is by using client-side JavaScript and XML.

An good example (e.g. used by Michael Schwarz for demonstrating Ajax.NET) is the case where the master dropdown shows a list of car brands, and the detail dropdown shows a list of available models for the selected brand. When the user selects a car brand, the car model dropdown is filled clientside, so no need for a postback to the webserver!

I've assembled an example project containing 4 techniques for implementing Master-Detail dropdowns in ASP.NET, which you can download here (including source code!!!). The 4 techniques in my example project are:

  1. Server-side using ASP.NET 1.x/2.0 AutoPostBack
  2. Client-side using ASP.NET 2.0 (beta 2) Client Script Callback
  3. Client-side using ASP.NET 1.x/2.0 Ajax.NET
  4. Client-side using ASP.NET 2.0 (beta 2) Atlas script

Note: For these examples to work, you need ASP.NET 2.0 beta 2 installed. For the examples to run on RC, some changes have to be made for the Client Script Callback example.
Note2: Thanks to Bertrand Le Roy for helping me out on the Atlas code!

A few things I haven't solved for the Atlas example yet:

  • The databinding of the detail dropdown needs the selectedValue of the master dropdown. Someway, I can't just bind this value direct from the dropdown, so I used a hidden textbox for this (binded to the selectedValue of the master dropdown).
  • I use the AtlasScript 'setProperty' to enable/disable the postback button. I want to enable the button when the selectedValue of the detail dropdown is unequal to an empty string, but I cant' seem to find a transformation function for a comparison like this.

Please give me feedback when you think my Atlas example could be improved.



Continuous Integration for Visual Studio 2005 Team System beta 2

Wed, 20 Jul 2005 00:21:00 GMT

As you may or may not know, the current beta 2 version of Visual Studio 2005 Team System only supports manual team builds against the Team Foundation server. I think the final release of VSTS is going to support scheduled builds (e.g. nightly builds), but I don't think continuous integration will be supported (because Microsoft don't practice CI themselves).

However my company enforces their developers to use Continuous Integration on all projects, so I had to build a CI process for Team System myself.
I thought it was a good idea to share the results with you :)

I enabled continuous integration by setting up a scheduled MSBuild project that runs every 5 minutes. It includes 4 custom MSBuild Tasks I've created (also see Visio drawing at the bottom):

  • CheckWorkspaceUpToDate : Checks if any files were changed on the local server workspace since last run. Uses the h.exe (as of Hatteras) command.
  • StartTeamBuild : Starts a Team Build by calling the BuildContoller.asmx WebServices (thanks to Aaron Engel for sample code)
  • GetUnexaminedBuild : If available, returns a finished build from Team Foundation where build quality is "Unexamed". The status of this build will be notified to all team members using messenger, and the build's build quality will be set to 'Notification Sent'.
  • MessengerNotification : Task to send an arbitrary message through MSN messenger (using SendMSN that uses the DotMSN library; thanks to James Simmonds and B.Geertsema)

Because you're all such nice people, I decided to share my code and binaries. Download it here.

To run this Continuous Integration process on your own server, take the following steps:

  1. Create a Team Build using the wizard in Team System (if you already have created a Team Build, skip this step).
  2. Create a workspace on your server, and map your project's repository-folder to a local file folder on that server. Do a 'Get Latest' on this folder. Note: first time you do a teambuild, a workspace will automatically be created on the buildserver; it's best to use this generated workspace.
  3. From the downloaded zip, extract "Macaw.MSBuild.Tasks.dll" and "DotMSN.dll" (or build them yourself). Add these libraries to the GAC.
  4. From the downloaded zip, extract "/MSBuild Examples/ContinuousIntegration.proj" and put this somewhere on your hard disk (e.g. c:\teambuilder)
  5. Edit the ContinuousIntegration.proj MSBuild project, and change all properties in the to match your environment.
  6. Test ContinuousIntegration.proj (run as argument of MSBuild.exe, which can be found in the .NET framework folder).
  7. If ContinuousIntegration.proj is working well, schedule it to run every 5 minutes: schtasks /create /SC MINUTE /MO 5 /TR [batch file to run] /TN [scheduled task name]. Note: The [batch file to run] should contain a command like: "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\MSBuild.exe c:\teambuilder\continuousintegration.proj".


FireFox doesn't understand a DOM node-tree?

Thu, 23 Jun 2005 20:47:00 GMT

Have a look at this HTML snippet. When clicking the 'clickme' innerText of div2, I expect the browser to alert "div2", because div2 is the first child of its parent, div1.

<div id="div1">
<div id="div2" onclick="alert(this.parentNode.childNodes[0].id)">clickmediv

I've tested this HTML snippet on both IE and FireFox, and guess what?
IE reacts as expected by alerting "div2".
However, FireFox alerts "undefined"....?

Apparently, in FireFox div2 is considered to be the second childNode of div1; not the first. I guess this is because FireFox parses the whitespace between div1 and div2 as being a seperate node! BUT WHY????

Did the creators of FireFox (Mozilla Foundation) implemented this by design? Is it ever going to be fixed in FireFox? Or do we just have to live with it, and write seperate javascript for IE and FireFox?

[Note: of course I can let IE and FF return the same results by removing all whitespace between the div1 and div2 tags, but that would result in human-unreadable and hard to maintain Html.]

I've received a lot of comments about the fact that FireFox precisely (I'd say 'rigidly') follows the w3c DOM recommendation on this. I'm aware of the w3c specs, but I still think it sucks having to write seperate code for IE and FF (or include a library of wrapper functions).
Personally, I think the IE dom-representation is the more sensible one, whether it's in the recommendation or not.
And FireFox just made a very bad 'first impression' to me :(

Read these links on more information why Mozilla has chosen to preserve whitespaces in the DOM:

Expand/Collapse EditorParts (ASP.NET 2.0 Portal Framework)

Wed, 22 Jun 2005 22:33:00 GMT

If you've been experimenting with the ASP.NET 2.0 Portal Framework (like me!), you know there are 4 out-of-the-box EditorParts that you can place in the EditorZone (the EditorZone is the Zone where you can edit a WebPart's properties). The 4 standard EditorParts are: PropertyGridEditorPart AppearanceEditorPart BehaviorEditorPart LayoutEditorPart The Problem These EditorParts work great. However, if you place all 4 EditorParts in the EditorZone, they will show a very long list of editable properties. Not very user-friendly. The Solution By using stylesheet classes and a little client-side javascript, you can make the EditorParts expand and collapse when you click on their titles. You can even show a cool plus/minus icon next to the EditorPart's title (see screenshot). How it's done: The Code In the EditorZone tag, set the CssClass-attribute of the EditorParts you want default to be collapsed to 'EditorPartHidden' (this is a css class I'll show you later on). Also set the CssClass of the PartTitleStyle to 'EditorPartTitle' (so a client-side behavior can set on the EditorPart's title).                   Next you can see the 'EditorPartHidden' and 'EditorPartTitle' css classes (put these in your stylesheet). Note that the 'EditorPartTitle' class is using a background image to show the 'plus' sign next to the title (also needs a padding-left to move the title a bit to the right, otherwise the title will be placed on top of the 'plus' sign).A behavior ( is set on the EditorPartTitle to perform the expand/collapse. Note: behaviors are IE 5.5+ only (or does FireFox supports this also?).Note: I replaced the .htc (IE only behavior) by cross-browser javascript. .EditorPartHidden{  display: none;} .EditorPartTitle{  behavior: url(htc/; //note: I replaced the .htc (IE only) by cross-browser javascript  background-position: left;  background-repeat: no-repeat;  background-image: url(images/plus.gif);  cursor: pointer;  padding-left: 14px;  font-size: x-small;} ...and this is the javascript code for the expand/collapse behavior. It sets onclick events to all EditorPart titles, which toggles the image (plus/minus) and the EditorPart's content. Include this code on your .aspx page (or use Page.ClientScript.RegisterClientScriptBlock).       ClientExceptionLogger.asmx.cs: namespace ClientExceptionLogging {   public class ClientExceptionLogger : System.Web.Services.WebService   {     [System.Web.Services.WebMethod]     public int Log(       string msg,       string url,       string sLine,       string navigatorAppName,       string navigatorAppVersion)     {       //TODO: do your logging here (I prefer Log4NET at the moment)         //for testing purposes: return fake LogEntry ID       return new System.Random().Next(int.MaxValue);     }   } }[...]

Healthmonitoring in ASP.NET 2.0 (EIF++)

Thu, 09 Dec 2004 20:34:00 GMT

The next version of ASP.NET (2.0) finally comes with a built-in logging mechanism: Healthmonitoring.I've just been experimenting with it (using my Visual Web Developer 2005 Express Edition Beta1), and it really rocks! It's got the power of EIF (Enterprise Instrumentation Framework) combined with the simplicity of Log4NET. Moreover, ASP.NET 2.0 Healthmonitoring offers a lot of common event-sinks, like EvenLog, Email, TemplatedEmail, File, Wmi and SQLServer. Besides logging of events, there's a 'heartbeat' feature, giving you the power to do monitoring of your app. There's still very little (like "none") documentation about Healthmonitoring, so maybe you want to know how I managed to log my own events to the default ASP.NET SQLServer sink: Step 1: run aspnet_regsql.exe; this will create the 'aspnetdb' database on your SQLServerStep 2: create your own event derived from a BaseEvent (I called mine 'MyWebEvent'). Note: only custom events with an eventCode > WebEventCodes.WebExtendedBase will be logged by ASP.NET 2.0! public class MyWebEvent : WebBaseEvent{    public MyWebEvent(string msg, object eventSource, int eventCode) :      base(msg, eventSource,WebEventCodes.WebExtendedBase + eventCode) {}   public MyWebEvent(string msg, object eventSource, int eventCode, int eventDetailCode) :      base(msg, eventSource, WebEventCodes.WebExtendedBase + eventCode, eventDetailCode) {}    public override void Raise()   {      base.Raise();   }} Step 3. Enable healthMonitoring in your web.config (see below). Besides my own 'MyWebEvent' events, I also log all Exceptions that were raised in my webapp (as you can see in the 'rules' section). If you want to know what the default built-in Providers, EventMappings and Rules are, please have a look at the 'machine.config.comments' file (inside the Config folder of your .NET installation). Note: when you've put your event-class code in the /Code folder, please first do a 'build all' before enabling healthMonitoring in your web.config (else ASP.NET 2.0 won't be able to create the type of your event).                                                              Step 4. Now raise your own event somewhere in your web-application !! MyWebEvent myWebEvent = new MyWebEvent("Dion was here", this, 1);myWebEvent.Raise(); See also:  [...]

Introducing PortalFx (ASP.NET 2.0 webpart extensions)

Sun, 26 Sep 2004 12:13:00 GMT

The goal of PortalFx -one of my 'home' projects- is to extend the default functionality of the ASP.NET 2.0 portal framework and its webparts. What triggered me was the '[WebBrowsable]' attribute in ASP.NET Whidbey, which allows you to add custom web-editable properties to a WebPart. When editing the WebPart, these custom properties are added to the 'Custom Settings' box. However, just plain textboxes are shown to edit the values of the custom properties. And of course, I want much more than just  textboxes :) So PortalFx was born... Some things PortalFx offers so far:* 'Add New Page' functionality (adding a new aspx portal page on the fly)* Custom EditorParts (dropdown, rich text editor, date selector using regional settings, etc.)* Validators (so the data entered in the custom editors can be validated)* CSS classes, which you can use to give the editor-parts look&feel from a stylesheet* ListItemProviders, which are used to fill the dropdown lists with values PortalFx mainly based on Macaw's XPortal framework ( and also uses HtmlArea v2.03 ( My regards go to XPortal's creators: Roel Bergsma, Richard Kuperus and Vincent van Proosdij. Screenshot 1: Adding a new portal page Screenshot 2: Editing a PortalFx WebPart To make use of this additional functionality, I've created a PortalFxWebPart baseclass. Once your webpart inherits from this baseclass, you can add the special PortalFx attributes to the editable properties in your webpart. For instance, if you need a rich textbox the edit the text in your property, you've only got to add a attribute [PortalFxBrowsable(EditorStyle.RichText)] to your class property. That's all! Example 1: RichText editor [Personalizable] [PortalFxBrowsable(EditorStyle.RichText, "Body text")] public string MyRichText {   get {return _myRichText;}   set {_myRichText = value;}} Example 2: Required text editor [Personalizable][PortalFxBrowsable(EditorStyle.Text, "Required text", "RequiredTextCssClass")][PortalFxValidator (ValidatorType.RequiredField, "Please enter some text!")]public string MyText {  get {return _myText;}   set {_myText = value;}} Example 3: Date editor [Personalizable][PortalFxBrowsable (EditorStyle.Date, "Birthdate")]public DateTime BirthDate {  get {return _birthDate;}   set {_birthDate = value;}} Example 4: Dropdown of values [Personalizable][PortalFxBrowsable (EditorStyle.DropDown, "Dropdown of values")][PortalFxListItems (typeof(ListItemProviders.StringValueListItemProvider), new object[] {"value1","value2"})]public string MyChoice {  get {return _myChoice;}  set {_myChoice = value;}} I will post the source-code soon on my weblog!Postscript: We're building a commercial portal-solution on this code now, so I can't release the sources. I suggest you try the 'WebPart components' project by Fredrik Normen, which has simular features (see overview here).[...]

Adding a 'ValueChangedOnPostback' property to TextBox, DropDownList, CheckBox, RadioButton, etc.

Sat, 18 Sep 2004 07:18:00 GMT

For my current project I'm building a framework that automatically saves all form-data on a page postback. Because a save-operation is time consuming, I want the framework only to save the information when the user really changed the data on the page.

For this, the ASP.NET framework offers a 'changed' event for each editor (TextBox, DropDownList, etc.) . E.g. when a user has changed the value in a textbox, the TextChanged event will be fired somewhere after the Page_Load and before the Page_OnPreRender event. This basically was my problem: I needed to know if the textbox was changed in the Page_Load eventhandler, not after. The TextChanged event of the TextBox just fired to late for me.

My solution was to write my own edit-controls that all inherited from their corresponding System.Web.UI.WebControls classes. All my custom edit-controls implement the IPostBackDataHandler interface, so the ASP.NET framework will call the LoadPostData method somewhere between the Init and the Load event. Also, I added my own IPostBackDataChanged interface, containing the boolean property 'ValueChangedOnPostback'. This property I can now read on the Page_Load event to know if the data of the TextBox was changed by the user.

Example code for my custom TextBox:

namespace MyProject.Web.UI.WebControls
   public class TextBox : System.Web.UI.WebControls.TextBox, IPostBackDataHandler, IPostBackDataChanged
      private bool _valueChangedOnPostback = false;
      public bool ValueChangedOnPostback
get { return _valueChangedOnPostback; }

      bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
         string text1 = this.Text;
         string text2 = postCollection[postDataKey];
         if (!text1.Equals(text2))
            this.Text = text2;
            _valueChangedOnPostback = true;
         return _valueChangedOnPostback;
      void IPostBackDataHandler.RaisePostDataChangedEvent()

Is Microsoft trying to discourage the use of Remoting?

Fri, 27 Aug 2004 21:28:00 GMT

After visiting the TechED Europe 2004 in Amsterdam, it seemed to me that Microsoft was trying to deprecate Remoting as a solution for distributed architectures.

I guess it's because the forthcoming 'Indigo' is built upon (and extending) WebServices functionality, and Remoting just doesn't fit in very well here. During the TechED there was not a single session on Remoting, while I guess there were over 30 sessions on WebServices and SOA's. A couple of well-known speakers called Remoting an immature framework, and accused it of being built too hastily as a .NET alternative for DCOM. And even some slides were presented that showed Binary Remoting being twice as slow as Http WebServices (on a IIS6 machine that is).

What?? How is that possible?!! How can a Microsoft-specific binary remoting architecture be much slower than utf-8 WebServices? Why where these results shown now, while at the launch of .NET 1.0, Remoting was presented as the fasted solution for distributes systems?

So my conclusion: Microsoft is trying to discourage people to use Remoting, because Indigo will not support it very well. While I understand the reasons they do this (I myself am a big fan of WebServices and the power of SoapExtentions), I still don't understand how Remoting can be that slow compared to WebServices. I guess Microsoft has put a lot of effort in IIS6 to optimize it for WebServices?