DXperience ASP.NET Subscription Giveaway

DevExpressWell, its time for another great giveaway. This time the great people at Devexpress have offered one of their premier products worth $799.99!

For this giveaway, you have a chance to win one license of DXperience ASP.NET Subscription with over 20+ ASP.NET controls. In addition, you’ll get updates and support too for a full year!

Giveaway Rules

The contest will start today, September 2nd, 2009, and last 7 days concluding on September 8th, 2009 11:59PM. At that point I will pick the winner and announce the results on the following day.

In order to signup for the giveaway you need to do 3 things…

  1. Follow @elijahmanor on Twitter
  2. Tweet the following…
  3. Add a comment to this blog including your Twitter username

At the end of the contest I will pick a random comment from this blog entry and then make sure the comment author tweeted the above RT. At that point I will Direct Message the winner (which is why you need to follow @elijahmanor) with further instructions to receive the DXperience ASP.NET Subscription.

Note: Unlike my last giveaway, I decided that you can add multiple comments to this blog post, but only one per day per person. Multiple comments from the same person in one day is kind, but will not help you win and could just disqualify you from the contest. So please, come by once a day during the contest and leave a comment below. This increases you chances of winning.

More About the DXperience ASP.NET Subscription

Want to learn more about the awesome prize? I highly recommend you check out the following:

1. The DevExpress Online Demos are the quickest way to play with the ASP.NET controls that you might win

2. Download the fully-functioning trial and test drive the controls locally in your Visual Studio

3. Check out their blogs, they've got some great content up there

4. DevExpress has a big developer fan base and their Facebook Page shows this enthusiasm and excitement. Become a fan by going to this page

Winner Announced…

Congratulations to Matt Lacey for winning the DXperience ASP.NET Subscription giveaway! Someone from DevExpress will be contacting you shortly with instructions. Thank you for everyone who participated in the contest. I hope to have other giveaways in the future. Stay tuned ;)

Read More »

jQuery UI Dialog w/ Resizable iFrame

Today I went looking for a jQuery Modal Plugin that would allow me to display resizeable iframe content.

Although there are many jQuery Modal Plugins out there, there are not many that support iframe content. Out of those that openly support the iframe, I personally didn’t think they look all that good and I didn’t see any that supported the resize feature.

So, then I decided to take a deeper dive into the the jQuery UI Dialog Plugin to see what could be possible. Upon further scrutiny, I found that as of June 25, 2008 @rworth added functionality to the the plugin to support autoResize.

All I really had to do was create an iframe, call the jQuery UI Dialog, turn on the autoResize, do some initial resizing, and presto chango… a resizable modal with iframe content was born!











Feel free to check out the online demo of the above code and/or download the files yourself if you want.

Read More »

Unblocking Assembly Due to AspNetHostingPermission Security Exception

Ok, I am one of those strange birds who jumped over Windows Vista and went straight from Windows XP to Window 7, so I haven’t had the pleasure to experience many of the security features that supposedly protect the user from themselves.

After banging my head on the proverbial wall one too many times, I finally figured out the cause of a Security Exception I was getting while trying to add xVal Validation Framework into my ASP.NET MVC v2 Preview 1 project.

“System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.”

SecurityException

It appears that Windows 7 (and from what I’ve heard Windows Vista also does this as well) attempted to protect me from a potential threat! When looking at the file properties dialog of the xVal.dll there was a security message at the bottom stating…

“This file came from another computer and might be blocked to help protect this computer.”

UnblockAssemblyIt turns out that all I had to do is click the “Unblock” button next to the message, remove & readd my Visual Studio project reference, and viola my problems were solved!

Next time, I hope not to waste half my day trying to figure this out. If you have not already faced this pain, I hope that you don’t have to in the future, or that this post will help you resolve it quickly!

Read More »

ASP.NET MVC V2 Preview 1 Strongly Typed UI Helper Performance

I am sure many of you ASP.NET MVC enthusiasts have either examined, downloaded, or started to play around with the ASP.NET MVC V2 Preview 1 release.

One of the many new features is the concept of Strongly Typed UI Helpers such as Html.DisplayFor() & Html.EditorFor() which take a Lambda Expression as their argument. This is a great new feature because we can now get compile time checking of our arguments and it provides the ability to easily refactor changes across our project. The old version of the Html Helpers were littered with Magic Strings that were susceptible to error and painfully resistant to change.

I was talking to a co-worker at Sommet Group, Alex Robson, about the new Strongly Typed UI Helpers and he immediately became curious as to whether the helpers use Lambda Compiles to obtain the Model’s value. I checked the source code of the ASP.NET MVC V2 Preview 1 release and found the following code snippet from TemplateHelpers.cs…

internal static void TemplateFor<TModel, TValue>(this HtmlHelper html, Expression<Func<TModel, TValue>> expression, string templateName, string htmlFieldId, DataBoundControlMode mode) where TModel : class {
object modelValue = null;
try {
modelValue = expression.Compile()(html.ViewData.Model);
}
catch (NullReferenceException) { } // Okay if it throws a null ref exception, we can infer types without the actual data
//Etc...
}</pre>

The reason for the concern is that he read a recent slide deck by Rudi Benkovic reviewing several performance issues of which Lambda Compiles were a hot topic.

The Experiment

With Alex’s experience developing the Open Source project Nvigorate, he has had a lot of experience working with Lamdas, Reflection, and the like. So, he started on a mission to compare various dynamic access methods and to compare their performance. The following graph provides a high level summary of Alex's findings. You can also read his detailed post from his blog and download his sample code. 

DynamicAccessMethodPerformance

As you can see from the graph above, the Lambda Compile is by far the least efficient way to obtain the model’s value when compared with Dynamic Methods, Type Descriptor, and Reflection. The worst part is that the Lambda Compile and Dynamic Method approaches both scaled poorly when the number of test cases increased.

Why Should I Care?

You might be thinking, “Who would actually use 1,000 or even 10,000 instances of the Html.EditorFor() anyway? Why does this really even matter?”.

The answer is that we shouldn’t just be concerned about the current page request, but also with the overall scalability of our website as the number of concurrent page requests increase.

What Now?

The good news is that the API for the Strongly Typed UI Helpers don’t need to change in order to accommodate these speed performances. All of Alex’s tests start with a Lambda Expression…

public static void Reflect<TModel, TProperty>(Expression<Func<TModel, TProperty>> expression, TModel instance)
{
var val = typeof(TModel).GetProperty(GetMemberFromExpression(expression)).GetValue(instance, new object[] {});
Debug.Assert(val.Equals("Dude"));
}

public static void TypeDescriptorCall<TModel, TProperty>(Expression<Func<TModel, TProperty>> expression, TModel instance)
{
var properties = TypeDescriptor.GetProperties(typeof(TModel));
var property = properties.Find(GetMemberFromExpression(expression), false);
TProperty val = (TProperty)property.GetValue(instance);
Debug.Assert(val.Equals("Dude"));
}

public static void DynamicMethodCall<TModel, TProperty>(Expression<Func<TModel, TProperty>> expression, TModel instance)
{
var delegateCall = DynamicMethodFactory.CreateGetter(typeof(TModel).GetProperty(GetMemberFromExpression(expression)));
var val = delegateCall(instance);
Debug.Assert(val.Equals("Dude"));
}

public static void LambdaCompile<TModel, TProperty>(Expression<Func<TModel, TProperty>> expression, TModel instance)
{
var val = expression.Compile()(instance);
Debug.Assert(val.Equals("Dude"));
}

Summary

Based on some initial work done by Rudi Benkovic as seen in his slide deck, it came to our attention that Lamda Compiles can be very slow and actually affect website scaling when using ASP.NET MVC.

Thanks to Alex Robson, he compared 4 different dynamic access methods and compared their performance. His findings showed that using a Lamda Compile was the slowest of the 4 approaches tested when obtaining a Model’s value from a Lambda Expression. In contrast, Reflection was by far the fastest approach to consistently retrieve a Model’s value.

I hope the ASP.NET MVC team will take note of these findings and consider using Reflection instead of Compiling the Lamda inside of their next preview release.

Read More »

Goodbye Google Adsense And Hello The Lounge

TheLounge2_thumb

Out With The Old

On my previous blog I used to use the Google AdSense, but it quickly became a nuisance. Not only was my webpage cluttered with irrelevant Ads (usually off topic & sometimes offensive), but I could only get at most pennies a day in earnings.

I tried several approaches to get higher click-rates (by rearranging my ads, placing multiple ad blocks, changing colors, etc…), but in the end I think it annoyed my readers and it really didn’t provide the revenue that I had expected or desired.

In With The New

Due to my experience with Google AdSense, my search for another web-based marketing tool began.

What I wanted out of my new provider…

  1. Ads that are actually relevant to my blog audience
  2. A trusted reputable service
  3. Potential for some actual revenue

After my search, I am pleased to inform you that I have joined The Lounge for my advertising network along-side these top bloggers…

If you blog about Microsoft technologies, then why don’t you consider joining The Lounge too?

Read More »