Using NTLM (Windows) authentication with RIA services#

When creating a new Silverlight business application using RIA services, it will automatically be configured to use Forms authentication. If you are developing an intranet application with single sign-on, you can easily switch the web.config to use Windows auth instead of forms. In my case, authentication still timed out, because the server still tried to access a database. You also have to disable the RoleManager and Profile services in the web.config to get Windows authentication running. This is a nice way to create out-of-browser intranet applications and still have single sign-on.

Tuesday, August 03, 2010 1:38:13 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

ASP.NET 4.0 web application always returns 404 error in IIS6#

Today, I had a Windows Server 2003 system, on which I freshly installed .NET 4.0 and wanted to deploy an ASP.NET 4.0 application in it. Sounds simple enough, but everytime I tried to access the application, I got a 404 error. In my case, I had an MVC2 application, for which I also enabled the wildcard mapping (I know, it's not required with 4.0, but I did it anyways, just in case). When it was enabled, I got 404s for every request. When I took it out, at least a simple text file was delivered instead of a 404 error.

Well, the solution was very simple, but it took a while to find. The ASP.NET 4.0 web service extension was disabled. So, if you keep getting 404s for your ASP.NET application, check in the Webservice Extensions folder in the IIS Manager if the ASP.NET 4.0 extension is enabled.

 |  | 
Sunday, July 25, 2010 10:26:18 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

550 Die verwendete Absenderadresse gehoert nicht zu Ihrem authentifizierten STRATO Paket.#

Today, one of my customers noticed, that the contact form on his site was not working anymore. Since nothing had changed for quite a while, I went to look, and it was actually so. A short check with the error returned from the SMTP mail library (PEAR_Mail) told me, the error was

550 Die verwendete Absenderadresse gehoert nicht zu Ihrem authentifizierten STRATO Paket.

For those of you who don't understand german, it translates roughly to "The used sender's address does not belong to your authenticated STRATO account." So I thought, no shit, it never has been, because I send the mails using the email address the user enters, so my customer can simply click "reply" in his mail program. This had never been a problem before, so why was it now. What complicated the matter even more, was that there is another form on the page, that also uses data entered by the user as the sender's address, and it worked perfectly well.

To keep things short: After tracing the tcp communication, I could not find any relevant difference. So, I tested sending a mail with a simple "This is a test" message. What can I say: It worked! Björn's an my guess is, that the STRATO mail server uses a spam filter and did not accept my mail due to its content. I removed some superfluous server data always submitted when sending a contact mail, and now things are working again. That error message, though, is really misleading, and I hope they change it to something more meaningful.

So, if anyone else has this problem, try checking your mails content. It might be "spammy" :-)

Monday, November 16, 2009 5:08:01 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

OrderBy, Distinct, and LINQ's optimization skills#

Today, I was dumbfounded by LINQ's optimization skills. I built a query over a list of items, which have an assigned category and a display order. I wanted to fetch a list of the distinct categories, to display them as an overview, and have them sorted according to the order of the entries themselves. My LINQ query looked something like this:

var categories = context.Entries.OrderBy(e => e.DisplayOrder).Select(e => e.Category).Distinct();

Everything seemed to work, but when I started ordering things around, the categories would remain as they were. What I also noticed, was that they were ordered alphabetically, which perplexed me. I decided to look at the generated query, and lo and behold, there was not a single ORDER BY clause in it. I took the generated query, added my own order by clause to it, and got an error:

ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

Of course: Distinct probably just sorts the values to make filtering out duplicates easier. I left out the Distinct() method, and my ordering was the way I wanted to have it.

I have not yet worked on a sql-based solution for this, since my structure holding the categories handled duplicate filtering by itself. And my data barely has any duplicates in it anyways, so I left it at that.

But what amazed me, was that LINQ actually left out the order by on its own accord, since it would have caused an error. The LINQ to SQL parser really knows, what it's doing, although in my case, I would have liked to get some sort of warning, that the query will not behave as expected. Nonetheless, I love LINQ :-)

 |  | 
Thursday, July 16, 2009 12:04:26 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

jQuery UI DotNetNuke integration#

I just launched a new project at codeplex aiming at the integration of jQuery UI in DotNetNuke: http://jquidnn.codeplex.com/. The first releases are already available in form of DNN module packages containing the core functionality, including infrastructural code to include jQuery and jQuery UI, two web controls for the Tabs and Datepicker widgets, and the smoothness theme.

Also available are module packages for three more themes: Cupertino, UI Darkness and UI Lightness. Further skins are actually quite easy to package and will follow over time, or when someone issues a request for one ;-)

So please, start grabbing the releases and giving me feedback.

Friday, April 03, 2009 12:04:47 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Bogus errors from ASP.NET compiler#

I just wasted another hour, trying to figure out, what exactly ASP.NET was trying to tell me, when giving me an "ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl)." message on compiling my ascx file.

Ok, so I used a custom namespace, but I've done that hundreds of times, so that shouldn't be the problem. I also had a custom base class inheriting from UserControl. Also, nothing I haven't done before. So what was the issue now?!

I basically retyped everything concerning the namespace and class names in all files, but nothing helped. So I reverted to commenting out my code. This helped me find the issue: I used a

<% if (somethingOrOther) { %> Some code here <% } %>

construct in my ascx-file (Please don't start an argument on whether this is good practice or not. I know it's not the cleanest way to do things, but that is not the concern here :-) ), and actually forgot to put in the closing <% } %>. Ok, my fault, but shouldn't you get a better Compiler message than "ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl)."?!

So, if you encouter this error (and believe me, I've had it more than once due to typos), and are 100% positive you've spelled everything correctly, check for unbalanced parentheses!

 |  |  |  |  | 
Wednesday, March 18, 2009 5:43:48 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Be careful when reusing ListItems#

Yesterday, I had one of those WTF moments. I had a page with a form for entering two addresses. Both had the same fields, including a RadioButtonList with identical items. Since the items are resourced, I decided to optimize the performance by reusing the ListItems like so:

ListItem[] items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation.Items.AddRange(items);
this.salutation2.Items.AddRange(items);

Simple eh. Everything seems to be ok. And was I amazed, when I tested it, and I always got the SelectedItem to be the one selected in salutation2. I double-checked every location were I was storing the values, in case I forgot to change the field name after copy/pasting. But everything was correct, as far as I could tell. I even checked the values submitted by the browser, they were also correct.

Finally, it hit me: The ListItem has a Selected property, and it is used to find the RadioButtonLists SelectedItem property. And since I reused the items, the first list parses its items on postback, sets the appropriate ListItem's Selected property to true. Same thing happens with the second RadioButtonList. And since the ListItems are used in both lists, the last one wins.

So, I changed my code to look like this:

ListItem[] items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation.Items.AddRange(items);
items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation2.Items.AddRange(items);

Now everything works as it should. So next time, be careful when reusing your ListItems!

 |  |  |  | 
Tuesday, March 17, 2009 12:12:24 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

Monty Python's Spamalot musical#

Last night, I went to visit Monty Python's Spamalot musical in Cologne. I had no idea, what to expect from it, and I was quite sceptical concerning the german translation. I was very surprised by the job, the whole team has done. It was very funny, in typical Monty Python style, many unexpected gags, and very ludicrous. I actually believe, they got some gags in german, that weren't in the english version. At least, I wouldn't know, how to translate it, to make it funny :-) I'm very interested in the english version, though. Humor is definitely best in the original language. Nonetheless, the musical is definitely worth seeing.

Thursday, January 29, 2009 1:29:07 PM (W. Europe Standard Time, UTC+01:00)
Comments [0]  | 

 

All content © 2010 , Christoph Herold