Archive for August, 2008

August 29th, 2008

ASP.NET MVC Preview Release 5

Looks like the MVC team has put out preview release 5 of the MVC Framework today.  You can get the latest version from CodePlex.

Here is what I can tell has changed from the release notes.

What’s New

  • Added global registration of view engines
  • Changed the IViewEngine interface to add the RenderParial method
  • Added support for rendering partial views
  • Added a parameter to specify a default option label for DropDownList controls
  • Moved ASP.NET AJAX extension methods to a separate namespace
  • Added helpers for RadioButton and TextArea controls and made overall improvements to other helpers.
  • Removed helper method overloads to avoid ambiguity
  • Added array support for action method parameters
  • Removed the ActionMethod property from action filter context objects
  • Added support for custom model binders
  • Added an IActionInvoker interface
  • Added an UpdateMode method to the Controller class
  • Changed HandleErrorAttribute so that it does not handle exceptions when HttpContext.IsCustomErrorEnabled is false
  • Added a new AcceptVerbs attribute
  • Added a new ActionName attribute

Known Issues and Breaking Changes

  • Controller class now is derived from ControllerBase class
  • Controller.Execute as removed, it is not called ExecuteCore.
  • Controller initialization steps should be done in Initialize method now.
  • IViewEngine interface is now responsible for finding views, not rendering them.
  • Some overloads to some helper methods have been removed.
  • AJAX helper methods have been moved to a new namespace.
  • This version is incompatible with Visual Studio 2008 SP1 Beta

Upgrading from Preview 4 to Preview 5

  • System.Web.Abstractions and System.Web.Routing have been changed to version 3.5.0.0
  • Assemblies are located at %ProgramFiles%\Microsoft ASP.NET\ASP.NET MVC CodePlex Preview 5

Derik also noticed that many of the classes are still sealed, and is requesting that the team un-seals all classes, and I agree with him.

Breaking and mysterious changes that I have submitted a bug request for:

Update (2008-8-31): Also Derik found a replacement for RenderUserControl, very minor change, but it is the difference between a error and having the thing work.

Tags: ,

Posted in News | kick it on DotNetKicks.com | Bookmark | View blog reactions | 3 Comments »

August 27th, 2008

So I received an iPhone last week…

I have to preface what I am about to say with a couple of things:

  • I have a first generation iPhone
  • I do not have AT&T or any other GSM network
  • I am using this iPhone as a phone mostly as an iPod
  • I use Verizon Wireless as my cell phone provider

I have to say I am pretty impressed with the iPhone interface.  Alot of work has been done with the user interface and making the applications very useable.  But I have noticed the following problems, that wouldn’t nessisary keep me away from this as a phone, but would make me think twice about how usable it is from my point of view:

  • Microsoft Exchange support has been severely dumbed down, and forced in to the limited Apple model surround Mail, Calendar, and Contacts.
    • There are no categories for the Mail, Calendar, or Contacts.
    • There is no way to retrieve my tasks.
    • I use color coded calendar events for separation between Personal, IdeaPipe, and my Employer Voveo.  I have not been able to figure out the color coding that Apple seems to indicate on their Enterprise site.
  • No way to store and access files on the file system.  Which I use when I need a quick thumb drive in a pinch or to carry around presentations.
  • No Copy and Paste
  • Safari crashes under large downloads.  Especially on large pages that are not loaded via AJAX.  So it seems like buffering or rendering of complex web pages seems to be a problem.
  • No Flash or Java support on the “real web.”
  • Unable to make quick edits to Word, Excel, or PowerPoint documents, like I can do on a Windows Mobile device.
  • It is very hard to develop a native application for the iPhone if you don’t have a Mac.  (sort of expected this one though)
  • No voice command software to read calendar events, dial phone numbers, or call somebody out of your contact list.  (not that I need the last two in my current situation)
  • No supported way to tether the iPhone to your computer to use it as a modem.
  • As well as the numerous 3G problems that seem to occur because of an immature 3G network.
  • Security is a second thought behind neat usability features.

The iPhone is a wonderful device, but in my oppinion it is still on the level of a toy, because it is generations behind Windows Mobile and Black Berry with features that are needed and wanted as an average business user. And at least Window Mobile and Black Berry keeps their devices locked and passcode protected, which is another reason Enterprises were probably wise to wait on rolling the iPhone out. Apple’s Exchange integration also seems sort of half assed, and they should have probably spent more time on providing some of the more basic features such as categories and tasks instead of creating a horribly buggy semi-quazi competitor with their MobileMe service.

All in all there is no complelling reason to move away from Verizon Wireless at this time for me.

Tags: , ,

Posted in Review | kick it on DotNetKicks.com | Bookmark | View blog reactions | No Comments »

August 25th, 2008

Deadlocked!: “read committed snapshot” Explained

I just recently read Jeff Atwood’s Deadlocked! article. I just wanted to give some more insight in to the read committed snapshot so that it is not perceived as “magic”. It has some definite advantages when dealing with deadlocks, however if your code relies on row level locking you are not going to be able to use this type of reading in SQL Server.

First lets talk about how you enable it. It is not a transactional isolation level, so if you set it, it will effect your whole database. You have been warned!

alter database [YourDatebaseHere]
set read_committed_snapshot on
go

Basically what this does is create a snapshot or read-only database of your current results that is separate from your live database. So when you run a SELECT statement, to read your data, you are reading from a read-only copy of your database. When you change your database, it happens on the live database, and then a new copy or snapshot is created for reading against.

Personally I am using it on IdeaPipe, because like most Web 2.0 applications there are a heavy amount of reads and very few updates that effect the row. So chances are if you have a website this will decrease your number of deadlocks. But make sure to test thoroughly before implementing read committed snapshot.

When I was doing my initial research a while ago I found this article talking about how snapshot isolation can bite you where it hurts.

For example, suppose READ COMMITTED SNAPSHOT is not enabled in the database and you want to assign one more ticket to a person, but only if that user does not already have high priority tickets:

BEGIN TRANSACTION
UPDATE Tickets SET AssignedTo = 6 WHERE TicketId = 1
AND NOT EXISTS(SELECT 1 FROM Tickets WHERE AssignedTo = 6 AND Priority='High')
--- do not commit yet

Note that you have not explicitly specified an isolation level, so your transaction runs under the default READ COMMITTED level. If another connection issues a similar update:

UPDATE Tickets SET AssignedTo = 6 WHERE TicketId = 2
AND NOT EXISTS(SELECT 1 FROM Tickets WHERE AssignedTo = 6 AND Priority='High')

it will hang in a lock waiting state. Once you commit your first transaction the second one will complete, but it will not assign ticket 2 to user 6, which is the correct behavior as designed.

However if read committed snapshot is enabled on the database the user will end up with two high priority tickets, because the first read happens against a snapshot and the update happens against the live database. So this will obviously cause problems for specifications and business rules that rely on row level locking. So be careful, and make sure you specifically know what is happening with your code before turning this on

Note: Chances are if you are using LINQ you don’t have to worry about the above scenario, however I am not a DBA expert, only a student of the practice. So take what I say with a grain of salt.

Tags: , , ,

Posted in How To | kick it on DotNetKicks.com | Bookmark | View blog reactions | 1 Comment »

August 14th, 2008

Is Stackoverflow.com really a Web 2.0 site?

I have been lucky enough to be one of the few and many people that have had the chance to preview the beta of stackoverflow.com. It has a very nice look and feel in my opinion and seems to work very well for an early beta. Jeff Atwood deserves major kudos. However I have had one plaguing question?

Is stackoverflow.com really a Web 2.0 site?

I started thinking about this question a couple days ago, because as many of you know I have my own project, that isn’t much different functionality wise than stack overflow. As I started cataloging everything that a Web 2.0 site is suppose to consist of, the more I asked the question what is a Web 2.0 site, and is stackoverflow.com really one?

Tim O’Reilly defines Web 2.0 as the following:

Web 2.0 is the business revolution in the computer industry caused by the move to the Internet as platform, and an attempt to understand the rules for success on that new platform.

In my opinion a platform has the following characteristics and so does a Web 2.0.  There are probably many more, but these are the top 4.

  1. It must have a fluent interface.  (this is usually implemented through AJAX)
  2. It must have an externally available API.  (because a closed platform is what Web 1.0 was all about)
  3. Users can own data and have control over who sees it.
  4. It is an obvious advancement from the previous Web 1.0 version of the software if one exisited.

http://stackoverflow.com

Just as a precursor to the following discussion, I have never heard Jeff proclaim that stack overflow is a Web 2.0 site, so this is just my ramblings.  Jeff has also done an awesome job with the site in a short period of time so everything I am saying now will probably change in the future.

Stackoverflow.com has only really done #1 of the first 3.  However what I really want to have a discussion on is if it really has advanced it self enough beyond the old forum model to really be considered 2.0 worthy or is it just a display layer on the 1.0.  For all intents and purposes we are going to use the forums on ASP.NET for comparison.

  • Allows users to create posts? (both yes)
  • Allows users to create reply to the posts? (both yes)
  • Allows users to talk to each other? (asp.net only)
  • Allows users to rank posts? (both yes, but different mechanisms)
  • Allows users to rank replies to posts? (stackoverflow.com only)
  • Allows users to get a system ranking against other users? (both yes)
  • Allows users to tag posts? (both yes)
  • Allows users to tag replies? (asp.net only)
  • Allows users to mark a reply as an answer? (both yes)
  • Allows categorization of posts? (asp.net only)
  • Users aquire badges of honor in the system? (both yes)
  • Users can have a profile of themself and their activity? (both yes)
  • Can easily follow a posting? (asp.net only)
  • Can easily follow a grouping of posts? (asp.net only)
  • Allow users to delete posts? (stackoverflow.com only)
  • Allow users to delete replies? (stackoverflow.com only)

Using the above questions it makes stackoverflow.com look like it is playing catch up to the asp.net forums, which has had a 6 year head start.  But it still begs to ask the question is the technology and application of it worth of the title 2.0 or just 1.1?  I think Jeff needs to impliment the following beyond the typical forum to really claim that 2.0 title.

  • An external API (REST seems popular)
  • Become less of a destination and more of a service:
    • Render in other platforms. (Facebook and/or Open Social)
    • Allow posting and following via SMS and IM.
  • Allow users to follow certain tags, categorizations, users, etc. through RSS, JSON, XML, etc.

I do beleive that Jeff has a long way to go before stack overflow is considered an advancement beyond the standard forum, but if anybody can make that leap it is Jeff.

Tags: , , ,

Posted in Review | kick it on DotNetKicks.com | Bookmark | View blog reactions | 1 Comment »

August 13th, 2008

Using a Parameter Attribute to set a Default Value in MVC

A couple days ago I came across a breaking change in ASP.NET MVC PR4 that wasn’t reported.  The breaking change is that defaults from routes are no longer used as defaults for parameters in the action method, if no appropriate parameter is found in the request.  Basically what this means is the following:

I have the following route:

URL: /home
Controller: Home
Action: Index
Defaults = page: 1

I set the page so that it always defaults to “1″ if no value is found in the query string for “page”.

So when a request is executed, the Route passes back the RouteData.Values = controller: “Home”, action: “Index”, page: 1. Then it goes through it’s normally processing and the value of the page’s query string is passed in to my action method for the page parameter. So if query string page = 1 then 1, query string page = 2 then 2, and so on. This is how it worked in PR3 and how I understood it was suppose to work as a concept.

However, in PR4, this doesn’t work anymore because of Line 166 in ControllerActionInvoker. It specifically checks that the value is in the route values. However they are always going to be in the route values if they have been defined as a default.

I reported it as a bug, because it was an obvious break from the last 3 preview releases and nothing was reported about this breaking change, and went on my merry way.  However today I received a message back from auriel confriming that this was the correct process flow, and that I should set the parameter either in my action method or the action filter.

So I decided to take this obvious disapointment and turn it in to something I have been thinking about for a long time, but never really had the motivation to impliment.  In .NET you are allowed to add attributes to anything that can be defined via reflection, including classes, interfaces, structures, and even return types and parameters of methods.  So I created an attribute called DefaultAttribute that is a parameter attribute that can be added to your action methods like this:

public ActionResult Index([Default(1)]int? page)

This method tells us that page has a default value of 1 if the value of page is null or undefined.  The DefaultAttribute is rather simplistic, because it is only suppose to hold the default value:

[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)]
public class DefaultAttribute : Attribute
{
	public DefaultAttribute(object @default)
	{
		if (@default == null)
			throw new ArgumentNullException("default");

		Default = @default;
	}

	public object Default
	{
		get;
		private set;
	}
}

As you can see from the above code I have told the attribute to only allow it to be attached to a parameter by specifying this in the AttributeUsageAttribute.  The next and last thing that we need inorder to complete our goal of being able to set the defaults in a parameter attribute is an action filter that can read the DefaultAttribute from the parameter and set the default if the parameter value is null or undefined.  We are going to process the parameter defaults in an action filter called UseActionParameterDefaultAttribute that can be attached to the controller or direction to the action method.  The code to process the defaults is:

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
	var defaults = GetDefaults(filterContext);
	var actionParameters = filterContext.ActionParameters;
	foreach (var value in defaults)
		if (actionParameters[value.Key] == null)
			actionParameters[value.Key] = value.Value;
}

internal static IDictionary>string, object< GetDefaults(ActionExecutingContext filterContext)
{
	string key = filterContext.ActionMethod.ToString() + "_ParameterDefaults";

	// get from application storage
	IDictionary>string, object< defaults = filterContext.HttpContext.Application[key] as IDictionary>string, object<;

	if (defaults == null)
	{
		defaults = new Dictionary>string, object<(filterContext.ActionParameters.Count);
		foreach (var parameter in filterContext.ActionMethod.GetParameters())
		{
			if (parameter.IsDefined(typeof(DefaultAttribute), false))
			{
				DefaultAttribute attr = parameter.GetCustomAttributes(typeof(DefaultAttribute), false)[0] as DefaultAttribute;
				string parameterName = parameter.Name;
				string actionName = filterContext.ActionMethod.Name;

				try
				{
					defaults.Add(parameterName, ConvertParameterType(attr.Default, parameter.ParameterType, parameterName, actionName));
				}
				catch (Exception exc)
				{
					throw new InvalidOperationException(String.Format(
						CultureInfo.CurrentUICulture,
						"The value of the DefaultAttribute could not be converted to the parameter '{0}' in action '{1}'.",
						parameterName, actionName), exc);
				}
			}
		}

		// add to application storage
		filterContext.HttpContext.Application[key] = defaults;
	}

	return defaults;
}

Each parameter of the action method is scanned for a DefaultAttribute and if found is added to the defaults dictionary to be used later when checking if each parameter is null or undefined in the OnActionExecuting method. Creating this code actually led to another request for the MVC team. The request was for a static storage collection for each action method so that compile-time code like attributes on the parameters don’t have to be processed with each request, since they can only possibly change when the code is recompiled. So I have my fingers crossed that they will actually implement this feature. In the mean time I implemented a application level storage for the parameter defaults so I don’t have to reprocess the parameters with each request.

I have added the two source files to my Google Code Project for Coder Journal, you can find them at:

Tags: , ,

Posted in ASP.NET | kick it on DotNetKicks.com | Bookmark | View blog reactions | 2 Comments »

August 12th, 2008

Visual Studio 2008 SP1 Released

Visual Studio 2008 SP1

  • Improved WPF designers
  • SQL Server 2008 support
  • ADO.NET Entity Designer
  • Visual Basic and Visual C++ components and tools (including an MFC-based Office 2007 style ‘Ribbon’)
  • Visual Studio Team System Team Foundation Server (TFS) addresses customer feedback on version control usability and performance, email integration with work item tracking and full support for hosting on SQL Server 2008
  • Richer JavaScript support, enhanced AJAX and data tools, and Web site deployment improvements

The .NET Framework 3.5 SP1

  • Performance increases between 20-45% for WPF-based applications – without having to change any code
  • WCF improvements that give developers more control over the way they access data and services
  • Streamlined installation experience for client applications
  • Improvements in the area of data platform, such as the ADO.NET Entity Framework, ADO.NET Data Services and support for SQL Server 2008’s new features

Team Foundation Server 2008 SP1

A number of improvements have been made to Visual Studio Team System 2008 Team Foundation including:

Version Control

  • Simplified the user experience through cleaner “Add to Source Control” dialogs, drag and drop support to the Source Control Explorer and a much easier to use “Workspace” dialog for working folder mappings.
  • Version control now automatically supports non-solution controlled files.
  • Various changes to the Source Control Explorer such as a new checkin date/time display column, local path hyperlink support and en editable source location field.

Work Item Tracking

  • Microsoft Office 2007 integration is now done using the standard Office “Ribbon” delivering a cleaner and easier to use integration to the different Microsoft Office 2007 products.
  • Email integration for work items and links for Team system Web Access to make it easier to use email as part of the development lifecycle.

Visual SourceSafe migration tool

  • The migration tool has been dramatically improved through many performance and reliability improvements. SP1 provides support for the elimination of namespace conflicts, automatic solution rebinding, improves timestamp coherency and increases the amount of migration logging information available.

Additional Features

  • Support for using SQL Server 2008 with Team Foundation Server.
  • Team System Web Access provides “live” links to work items and checkin emails. This improves the customer experience for users who do not use Team Explorer.
  • Scripting support for the creation of Team Projects.

Performance and scalability

  • With SP1 a large part of the focus was to improve the performance and scalability of Team Foundation Server through changes such as faster synchronization with Active Directory, improved checkin concurrency, a faster way to create source tree branches, online index rebuilding for less maintenance downtime and better support for very large checkin sets.
  • Improvements in the number of projects a server can support that make not only the scalability of the server better but also the client experience when connecting to a server with a large number of projects on it.

During the install, of TFS 2008 SP1, I received the error: Failed to call WMI on the RS server.  I did some searching on Google and found a post that I did back in November on the same problem.  I followed my exact same steps and it fixed the issue.  I don’t know why this DNS issue continues to cause Microsoft problems, but I really wish they would fix this bug.

Tags: , , , ,

Posted in News | kick it on DotNetKicks.com | Bookmark | View blog reactions | No Comments »

August 10th, 2008

MySQL Officially Declared Microsoft SQL Server Compeditor

I have been a huge fan of MySQL for a long time.  It is the perfect database for when the budget is tight or you are not working in a Microsoft Environment.  It performs well, and has a huge following of dedicated professional programmers that use it day in and day out on some of the largest websites on the planet.  Most noteable Facebook, Twitter, Flickr, and Digg.  Even with all these proven capabilities to scale and perform, Microsoft has choosen to ignore it and focus on some of the monolytic providers of databases such as IBM and Oracle when comparing SQL Server.

However that has all changed with the release of Microsoft SQL Server 2008.  Microsoft has set its focus on MySQL.  This is a huge turning point for both companies, because it means Microsoft is starting to take the needs of the Web 2.0 crowd, which MySQL has dominated, just as seriously as the big iron installs they have always catered to.

I am not sure if this comparison has been spured by the purchase of MySQL by Sun Microsystems, or if Microsoft has started to feel the preasure from Web 2.0 MySQL installs, or a little of both.  But none-the-less this is very encouraging, because it means that Microsoft is finally taking the needs of the “cloud developers” seriously.

Tags: , , , ,

Posted in News | kick it on DotNetKicks.com | Bookmark | View blog reactions | 3 Comments »

August 6th, 2008

I am ditching Vista for Windows Mojave

I just can’t take Windows Vista anymore so I am ditching it for Windows Mojave.  I have heard great things about it and anything must be better than Windows Vista.

Check it out for yourself:
http://www.mojaveexperiment.com

By the way, I am still alive, just very busy with some cool things that have been happening in my life.  I will share in the next couple of weeks.

Tags: ,

Posted in Uncategorized | kick it on DotNetKicks.com | Bookmark | View blog reactions | 1 Comment »