The World’s Leading Microsoft .NET Magazine
   
 
The .NET Addict's Blog

My Top Tags

                                                           

My RSS Feeds








I heart FeedBurner

Latest Diggs - Programming

Computers Blogs - Blog Top Sites

Site Hits

Total: 4,906,995
since: 19 Jan 2005

Fix for Minor Bug in ASP.NET MVC New Project Template

posted Sun 03 May 09

This evening I was plugging away at ASP.NET MVC 1.0 and I kept having a really weird problem with the default implementation of AccountController. Every time I tried to log in, I was getting some kind of annoying error about the "rememberMe" parameter being null.

I don't really know how this one slipped through the cracks and its more of a nitpick than a real bug, but it is application-breaking nonetheless. All you have to do in order to see the bug is attempt to log into the default ASP.NET MVC project after creating it and don't check the "remember me" box. I guess that edge case never got tested ;)

Anyway, the fix is quite easy. I just modified the signature of the LogOn method in AccountController to look like this:

public ActionResult LogOn(string userName, string password, bool? rememberMe, string returnUrl)

Notice that rememberMe is now a nullable parameter. Now you can't pass a nullable bool to the actual implementation of the LogOn method in the forms authentication service they provide, so you can just do something like this to pass along the appropriate information:

FormsAuth.SignIn(userName, rememberMe == true);

This will give you a meaningful default value of false.

Again, given the ridiculously high quality of ASP.NET MVC 1.0, I'm not really sure how this slipped through other than the idea that maybe most people yank out the default AccountController or all of the testers checked "remember me" :) Either way, it's a 30 second fix.

tags:      

links: digg this    del.icio.us    technorati    reddit

AddThis Social Bookmark Button




Tag Related Posts

Html.JqGrid - Cleaning up your jqGrid Code

Tue 22 Dec 09 8:46 P GMT-05
tags:              

How to Build your First Azure-Powered MVC App

Tue 29 Sep 09 2:16 P GMT-05
tags:        

ViewState is the Froo-It of the Dev-Il

Wed 23 Sep 09 3:09 P GMT-05
tags:      

Fix for Minor Bug in ASP.NET MVC New Project Template

Mon 04 May 09 2:48 A GMT-05
tags:      

NYC SharePoint Developer Needed

Mon 12 May 08 12:09 P GMT-05

Scott Guthrie Updates the ASP.NET MVC Roadmap

Wed 13 Feb 08 3:49 P GMT-05
tags:    

Volta is to Ajax what Tums is to my Stomach

Wed 30 Jan 08 4:11 P GMT-05

ASP.NET 3.5 Extensions Preview Released

Mon 10 Dec 07 2:10 P GMT-05

Microsoft unveils an MVC framework for ASP.NET

Mon 08 Oct 07 12:58 P GMT-05
tags:      

Exploring the MVC Pattern in WPF

Tue 10 Apr 07 12:51 P GMT-05
tags:                      

What I think is a bug in WCF POX messaging

Thu 04 Jan 07 4:58 P GMT-05
tags:      

ASP.NET Ajax v1.0 Beta

Fri 27 Oct 06 6:17 P GMT-05
tags:      

ASP.NET vs Ruby on Rails : Round 2 (Agility)

Thu 05 Oct 06 11:02 A GMT-05
tags:                      

ASP.NET vs Ruby on Rails : Round 1

Wed 04 Oct 06 1:37 P GMT-05
tags: