Thursday, September 24, 2009

Web Platform Installer

Microsoft has released an update to the Web Platform Installer application. If you are not familiar with this little tool, you need to check it out. Here is the overview from the product’s home page.

“The Microsoft Web Platform Installer 2.0 (Web PI) is a free tool that makes getting the latest components of the Microsoft Web Platform, including Internet Information Services (IIS), SQL Server Express, .NET Framework and Visual Web Developer easy. The Web PI also makes it easy to install and run the most popular free web applications for blogging, content management and more with the built-in Windows Web Application Gallery.”

Scott Guthrie also has a nice blog post about what it can do for you. When I upgraded to Windows 7, I used the Web Platform Installer to install SQL Server Express 2008 and configure my Web Server and IIS settings. It made the configuration very simple and straight forward. I highly recommend the use of this great application.

Friday, September 18, 2009

IIS Modules and Handlers - One web.config for Both IIS 6 and IIS 7

I recently started running my development projects on IIS 7 when I upgraded to Windows 7. I initially created a separate copy of the web.config with modified settings for the <httpHandlers> and <httpModules> sections as these need to move with IIS 7. In IIS 6 the <httpHandlers> and <httpModules> sections are located within the <system.web> section of the web.config file. However, with IIS 7 they need to be configured in the <system.webServer> section. So I did just that, I moved and modified those sections so that I could run in an Integrated App Pool. Please read How to Take Advantage of the IIS 7.0 Integrated Pipeline for more details on the differences between running in Integrated versus Classic mode.

However, I was recently looking into the ELMAH (Error Logging Modules and Handlers) Project and noticed in their demo application that they had thoroughly documented the IIS 6 and IIS 7 settings in their web.config and found this cool little comment:

<!--
    The <system.webServer> section is required for running ELMAH under Internet
    Information Services 7.0. It is not necessary for previous version of IIS.
    In general, it would be best to include it for all .NET Framework 2.0 and above
    configurations in order to have a more portable solution between various
    versions of IIS.

    IIS 5.x, IIS 6 require the modules and handlers to be declared in <system.web>
    whereas IIS 7 needs them declared here and complains if they are in fact
    declared in <system.web>. Fortunately, the
    <validation validateIntegratedModeConfiguration="false" /> entry tells IIS 7
    not to worry about the modules and handlers declared in <system.web>.

    If you only ever want to use IIS 7, then do the following:
    1. Remove handlers and modules from <system.web>
    2. Remove the <validation validateIntegratedModeConfiguration="false" /> element
-->

So I did a little research (Google search) on validateIntegratedModeConfiguration and found this MSDN Article on ValidationSection Class [IIS 7] that explains how this works.

Therefore, since myself and the other developers are still running a mixture of IIS 5.1 (Windows XP) and IIS 7 (Windows 7) I am going to update our shared web.config so that we no longer need to maintain separate versions of the web.config file for the different IIS versions, but can use one common one. This will make things a lot simpler. Then once we are all running on IIS 7, as well as all of our downstream environments, we can turn this off and remove the <httpHandlers> and <httpModules> entries in the <system.web> section.

Browser Chooser

Browser Chooser is a great little app that I ran across the other day.

Description from the Project Home Page on Codeplex:

“Browser Chooser is a small tool acting as the default browser allowing you to choose what browser to open the link in. It gives you the flexibility to choose what browser to use for any given task. It is developed in VB.Net and geared towards Windows Vista and Windows 7.”

I run Google Chrome as my default browser, but end up getting a lot of emails with links to content stored on SharePoint sites. My pain point before was that if the link was to a Word or Visio document, I cannot open it directly in Chrome and I would need to copy/paste the link into IE or Firefox. But now with Browser Chooser, I can select the browser to use when opening a link. Awesome!

Many thanks to Jan Ole Peek for creating this must have utility.

Go download it: http://browserchooser.codeplex.com/

Thursday, September 17, 2009

Are you a thriving developer?

I recently came across a great website Thrive For Developers. This is a Microsoft sponsored site that provides great resources to Advance Your Career, Enhance Your Skills or Connect With Your Community. We all know that times are tough, the economy is down and the job market is tough. Whether you are looking for a new career/position or to enhance your current one, there is a lot of great content that you should check out here. I am currently listening to the Driving Your Career – Soft Skills to Move You Forward series and have been learning a lot.

I would highly encourage anyone who is concerned about advancing their career (and that really should be everyone), to check this site out and take advantage of the many great resources that are available.

Tuesday, September 8, 2009

Filtering with LINQ

I recently refactored the display of data on a web page (in a Datagrid) from using a DataSet as the source to a List. As part of the original functionality, the list of items being displayed could be filtered based on selections that the user made. I decided to take advantage of the built in LINQ extension features for Lists to accomplish the filtering. The two extensions that I leveraged were the TrueForAll and Exists extensions.

 

In my first scenario, I have an object (Resource) that have a sub-List of times (TimeEntries) that represent their availability within a day. I need to filter the list to include all Resources in the list where their TimeEntries are not off (e.g. not on vacation, jury duty, break, etc.) In order to build that I used the TrueForAll extension that was examining a boolean method on the Resource object as shown below:

 

return resources.FindAll(r => r.Entries.TrueForAll(e => e.IsRegEntry()));





Additionally, I needed to filter the list to include the Resource if at least one of their entries was an Off entry, so for that I used the Exists extension as seen below:


 



return resources.FindAll(r => r.Entries.Exists(e => e.IsOffEntry()));





I am continually amazed at the power of LINQ and how it can make what was once fairly complex seem so much simpler and easier to understand. If you have an opportunity to check it out, I would highly recommend it.

Wednesday, September 2, 2009

SQL Server 2008 – Assign a default value to a local variable

I just discovered today, that SQL Server 2008 allows you to assign a default value to a local variable. I was not aware that this functionality had been added until I had a stored procedure I was working with on my local SQL 2008 database and tried to execute it on the shared development database, which is still running SQL 2005 and I received the following error:

Msg 139, Level 15, State 1, Procedure apGetRollCallData, Line 0
Cannot assign a default value to a local variable.
Msg 139, Level 15, State 1, Procedure apGetRollCallData, Line 0
Cannot assign a default value to a local variable.
Msg 137, Level 15, State 2, Procedure apGetRollCallData, Line 79
Must declare the scalar variable "@StartRange".
Msg 137, Level 15, State 2, Procedure apGetRollCallData, Line 89
Must declare the scalar variable "@StartRange".
  


I had the following declarations in my procedure that were causing the issue.




DECLARE @StartRange DATETIME = @ViewDate
DECLARE @EndRange DATETIME = @ViewDate





Once I changed it back to the following, it worked just fine in SQL Server 2005.




DECLARE @StartRange DATETIME
SET @StartRange = @ViewDate
DECLARE @EndRange DATETIME
SET @EndRange = @ViewDate



From a .NET developers point of view, I like having the ability to set a default value for a local variable in TSQL just like I can do in my programming language of choice.


 


Very nice. Thanks Microsoft.