Friday, July 29, 2011

ASP.NET MVC Telerik Extensions

After installing the ASP.NET MVC Telerik Extensions, we couldn’t get the custom htmlhelpers working when using the Razor syntax.

Finally we discovered that the namespace was added to the root web.config

<add namespace="Telerik.Web.Mvc.UI" />

were it should have been added in the ~/Views/Web.Config:

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />    
<pages pageBaseType="System.Web.Mvc.WebViewPage">      
<namespaces>        
<add namespace="System.Web.Mvc" />        
<add namespace="System.Web.Mvc.Ajax" />        
<add namespace="System.Web.Mvc.Html" />        
<add namespace="System.Web.Routing" />        
<add namespace="Telerik.Web.Mvc.UI" />      
</namespaces>    
</pages>  
</system.web.webPages.razor>

Now our program already compiles and runs. However we still had a problem with Intellisense in Visual Studio. For a reason we didn’t understand we still had to add a @using Telerik.Web.Mvc.UI in every view.

Anyone who can confirm that this is a bug in the Razor Intellisense?

Thursday, July 28, 2011

Windows Azure AppFabric July Release

This week Microsoft released several updates and enhancements to the Windows Azure AppFabric Management Portal and the Access Control service.

An overview:

  • Management Portal
    • Localization: the Windows Azure Platform Management Portal now supports the following extra languages: Japanese, German, Traditional Chinese, Simplified Chinese, French, Italian, Spanish, Korean, Russian, and Brazilian Portuguese.
    • Co-admin support:  Co-administrators have finally access to the AppFabric section of the portal.
    • Context Menus:the Portal now supports right click menus in the “Hosted Services, Storage & CDN” pane.
    • Performance Improvements: Users can expect to see significantly lower initial load times with the addition of a local temporary cache and the optimization of network bandwidth consumption.
    • Enhanced Delete Deployment: Developers can now delete running deployments. In earlier versions, developers had to wait for a deployment to stop before it could be deleted.
  • Access Control
    • Claim rules: The ACS 2.0 rules engine now supports a new type of rule that allows up to two input claims to be configured, instead of only one input claim. Rules with two input claims can be used to reduce the overall number of rules required to perform complex user authorization functions.
    • Encoding is now UTF-8 for all OAuth 2.0 responses
    • Quotas Removed:  The previous quotas on configuration data have been removed. This includes removal of all limitations on the number of identity providers, relying party applications, rule groups, rules, service identities, claim types, delegation records, issuers, keys, and addresses that can be created in a given ACS namespace.

More information:

Wednesday, July 20, 2011

Claims Based Authentication: SecurityTokenVisualizerControl

One useful control when developing Claims based web applications is the SecurityTokenVisualizerControl.

The Security Token Visualizer control (STVC) is a simple ASP.NET server control which displays in a compact layout useful information about claims-based identity in a web site secured with Windows Identity Foundation.
8de75977-9c90-4df4-b0c1-5daa603e3d38.png

The STVC is intended to be a debugging aid, which helps you to inspect what identity info you are receiving from the STS without the need for attaching a debugger to your website. Furthermore, STVC spares you the repetitive task of writing code that retrieves and render claim values or other info about the incoming security token that are typically needed in the development & testing phases of your application life cycle.

Only the source code is available but you can easily compile it yourself. Go check it out: http://archive.msdn.microsoft.com/TokenVisualizerCtrl.

Note: If you execute the installer without Visual Studio 2008 installed, skip the configuration wizard(it requires VS 2008).

Tuesday, July 19, 2011

Windows Azure Storage: One of the request inputs is out of range

Last week I ran into following error when trying to create a blob storage in Windows Azure:

“One of the request inputs is out of range” 

Let’s have a look at the code who causes this error. Do you see something special?

var blobStorage = storageAccount.CreateCloudBlobClient();
var blobContainer= blobStorage .GetContainerReference(“My Blob Storage”);
blobContainer.CreateIfNotExist();

I didn’t see something wrong.  But when I changed the reference name to “myblobstorage” suddenly everything worked fine. It seems that you cannot use any name you want for Windows Azure Storage containers. I discovered the following naming rules(maybe there are more):

  • use only lower case letters
  • digits are allowed anywhere
  • name should not contain any spaces

A more obvious error message would have been helpful.

Monday, July 18, 2011

Class Template is missing in Visual Studio

After playing around with Stylecop for a while, I decided to remove it from my system. So I just uninstalled it and everything seemed fine…until I tried to create a new class in Visual Studio. The class template was gone! I discovered that Stylecop replaces the default class template with it’s own one. However it doesn’t put the old one back in place after removing Stylecop.

So how do you get this template back?

I noticed inside the Visual Studio template folder(C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Code\1033) that the class template was still there but renamed. I changed it back to the original name and thought that the job was done. But I still had no class template available.

It took me some time to figure it out but in the end, I solved it by executing the following extra actions:

  • Close all Visual Studio instances.
  • Open a Visual Studio Command prompt.
  • Execute “devenv /InstallVSTemplates”. This command registers project or item templates that are located in <Visual Studio installation path>\Common7\IDE\ProjectTemplates\ or<Visual Studio installation path>\Common7\IDE\ItemTemplates\ so that they can be accessed through the New Project and Add New Item dialog boxes.
  • Execute “devenv /Setup”. This command forces Visual Studio to merge the resource metadata that describes menus, toolbars, and command groups from all VSPackages available.

Only after executing all these steps, my class template was back!

Sunday, July 17, 2011

Windows Azure Accelerator for Web Roles

Last week Microsoft announced the release of the Windows Azure Accelerator for Web Roles. This accelerator makes it quick and easy for you to deploy one or more websites across multiple Web Role instances using Web Deploy in less than 30 seconds. This solves on of the biggest issues when using Windows Azure as a hosting platform. No longer long coffee breaks before your application is deployed, but 30 seconds later you can run and test your site!

Feature highlights:

  • Deploy websites to Windows Azure in less than 30 seconds.
  • Enable deployments to multiple Web Role instances using Web Deploy from both Visual Studio and WebMatrix.
  • Saves Web Deploy packages & IIS configuration in Windows Azure storage to provide durability.
  • A Visual Studio Project template that allows you to create your web deploy host.
  • Full source and NuGet packages that you can use to build custom solutions.
  • Documentation to help you get started.

For additional information visit the following sites:

Friday, July 15, 2011

Good JavaScript Habits for C# Developers

A must see for every .NET (web) developer:

“It seems that far too many people come to jQuery thinking that their previous knowledge with object-oriented languages like C# or Java will help them be successful at client-side scripting. In many cases, you can be successful with this approach, however, the more JavaScript you write you will inevitably find yourself uncovering strange bugs because you didn't take time to learn JavaScript properly. This session is targeted for developers that use jQuery, but haven’t invested adequate time to learn some of the foundational JavaScript concepts that differ from C#. If you would like to avoid some of these common mistakes when bringing your existing expertise to JavaScript, then please join me as I try to explain some of the differences.”

Thursday, July 14, 2011

Microsoft - Domain Oriented N-Layered .NET 4.0 App Sample

Microsoft enters dangerous territory by trying to provide a sample of DDD(Domain Drive Design). It’s very hard to show the benefits of DDD in a simple sample, so I’m really curious how this will work out.

What I noticed immediatelly they start with a long list of things they will NOT try to do:

“This project/sample is willfully restricted to .NET implementation of most used patterns in N-Layered Domain Oriented Architectures based on simple scenarios easy to understand (Customers, Orders, Bank Transfers, etc.). This initiative is NOT trying to teach how to apply DDD. That shouldn't be Microsoft's goal and DDD is much more than Architecture & patterns implementation.
This is an Educational example, not a real world system, it shows educational scenarios, easy to understand useful from a patterns implementation point of view, but not necessarily as a whole business application. The architecture is decoupled and relatively complex so it would allow to grow your system.
Also, this sample goes along with our Architecture Guidance, and there are aspects in the guidance that are not covered by this sample, and viceversa.
Its main goal is to show how to use .NET 4.0 wave technologies implementing typical DDD patterns: N-Layered Architecture, Domain Entities, Aggregates, Repositories, Unit of Work, Domain Services, Application Services, DTOs, DTO-Adapters, etc.”

Although the sample is convoluted, they are still some things you can learn from it(how to NOT do things for example Winking smile).

What I find even more interesting as a learning experience is how Ayende Rahien jumped on this application and started a review series:

He even took up the challenge and is planning to create his own DDD sample. I’m looking forward to the result…

Wednesday, July 13, 2011

Windows Server 2008 R2: Assign permissions to ASP.NET v4.0 account

On our webservers (Windows Server 2008 R2 machines with IIS 7.5), our application pools run using the "ASP.NET v4.0" account instead of the NetworkService account.

But we had some trouble assigning permissions to this ASP.NET v4.0 account. It does not appear as a local user on the machine. When we browse for local users, groups, and built-in accounts, it does not appear in the list.

Luckily you can still add the user through the NTFS GUI by typing it in directly. The name is in the format of IIS APPPOOL{app pool name}. For example: IIS APPPOOL\ASP.NET v4.0.

Tuesday, July 12, 2011

Error when trying to download NuGet Package

At one of my customers we are creating our own internal NuGet server. This is very easy to setup thanks to the availability of the NuGet.Server package.

Create a new empty ASP.NET website, add the NuGet.Server package and deploy the solution, that’s all! New packages should be added to the available package folder and are automatically discovered by NuGet.Server.  This all worked fine until we tried to download our first package.

We got the following error back:

“The remote server returned an error: (401) Unauthorized.”

image001 (2)

We solved the issue by giving everyone read rights on the package folder. Afterwards we were able to download the packages fine.

Anyone with a different/better solution?

Monday, July 11, 2011

Be a ninja in the Cloud

Microsoft released version 2 of their Cloud Ninja Project. The Cloud Ninja is a Windows Azure multi-tenant sample application demonstrating metering and automated scaling concepts, as well as some common multi-tenant features such as automated provisioning and federated identity. They kept the code simple and easy to follow, making it easy for anyone looking through the application to follow the logic.

Key Features
  • Metering
  • Automated Scaling
  • Federated Identity
  • Provisioning

Contents

  • Sample source code
  • Design document
  • Setup guide
  • Sample walkthrough

cn-arch.png

Friday, July 8, 2011

The Visual Studio ALM rangers ship new ALM guidance

I noticed yesterday that the Visual Studio ALM rangers shipped some new guidance on ALM:

First of all they released the Rangers Lab Management Guide on Codeplex..

Project Description

This Visual Studio ALM Ranger project has the primary goal of delivering scenario based and hands-on guidance for the planning, setup, configuration and usage of Visual Studio Lab Management, backed by custom VM Template automation for reference environments.

The following Epics summarize the scope of the guidance which is designed for professional deployment of Lab Management in production environments.

  • Visualisation of the guidance using quick reference posters
  • Advanced golden image management using the VM Factory for Lab Management
  • Provide guidance on setting up Test environments with respect to pre-defined personas
  • Provide Guidance to enable large and small teams to setup and configure both automated and manual tests
  • Provide practical guidance for managing and maintaining a Lab Management environment
  • Provide practical guidance to enable teams to quickly setup and configure their lab management environment

They also released  Rangers Build Customization Guide on Codeplex.

Project Description

This Visual Studio ALM Ranger project has the primary goal of delivering scenario based and hands-on lab guidance for the customization and deployment of Team Foundation Build 2010 activities such as versioning, code signing, and branching.

What is in the downloads?

  • Guidance contains scenario based practical guidance, frequently asked questions and quick reference posters
    - Selected PDF contains guidance and quick reference posters in PDF format only.
    - Complete contains guidance, quick reference posters and localization files in all available formats.
  • Hands-on Labs (HOL) includes:
    - HOL documents that provide walkthroughs of the technology, based on the guidance
    - HOL Package contains a HOL environment setup package allowing you to setup the HOL environment in your own environment
    - BRDLite Build Process Reference Template walk-through.
  • Samples contains sample build process templates used by the team as part of the guidance.
  • Videos which showcase the guidance in quick 5-10min videos.

The Epics included in the guidance are:

  • Practical guidance and tooling to simplify the customization of Team Foundation Build
  • Practical guidance to use Team Foundation Build process templates to automate build and non-build scenarios in Microsoft environments
  • Practical guidance to enable simple and flexible deployment of applications and their data stores
  • Practical guidance for Activities to empower developers and build engineers
  • Quality hands-on labs that complement the guidance and effectively guide the user through the features
  • Visualization of the guidance using quick reference posters

Thursday, July 7, 2011

Exercise is the key to craftsmanship

How can you become better in what you are doing? The answer is simple; through exercise! This idea is practised a lot in software development through the usage of CodeKatas.

But CodeKatas suffer from their size. They are very small but this small size limits the methods, techniques, technologies that can be applied. To improve your TDD skills doing CodeKatas might be enough. But what about other skills? Developing on a software in a team, designing larger pieces of software, iteratively releasing software… all this and more is kinda hard to train using the tiny CodeKata problems.

Ralf Westphal introduces a new kind of exercise called Application Kata (or just AppKata).

“AppKatas are larger programming problems. They require the development of “whole” applications, i.e. not just one class or method, but bunches of classes accessible through a user interface. Also AppKata problems always are split into iterations. To get the most out of them, just look at the requirements of one iteration at a time. This way you´re closer to reality where requirements evolve in unexpected ways.”

So if you´re looking for more of a challenge for your software development skills, you can start with the following sample AppKatas that Ralf put on his blog:

CSV Viewer

An application to view CSV files. Sounds easy, but watch out! Requirements sometimes drastically change if the customer is happy with what you delivered.

Questionnaire

If you like GUI programming, this AppKata might be for you. It´s about an app to let people fill out questionnaires. Also this problem might be interestin for you, if you´re into DDD.

  • Iteration 1
  • Iteration 2 (to come)
  • Iteration 3 (to come)
  • Iteration 4 (to come)

Tic Tac Toe

For developers who like game programming. Although Tic Tac Toe is a trivial game, this AppKata poses some interesting infrastructure challenges. The GUI, however, stays simple; leave any 3D ambitions at home ;-)

  • Iteration 1
  • Iteration 2 (to come)
  • Iteration 3 (to come)
  • Iteration 4 (to come)
  • Iteration 5 (to come)

Wednesday, July 6, 2011

NDC 2011: Session videos online

If you couldn’t attend NDC 2011, you can try to keep up with all the interesting sessions you’ve missed. They’ve just put all the videos online. (There goes my remaining free time…)

Check them all out on the official website: www.ndc2011.no.

NDC 2011

Tuesday, July 5, 2011

Server hangs: DW20.exe

Last week the production server went down at one of my clients(woops…). The issue was that the IIS worker process, W3WP.exe was crashing when the users tried connecting to some websites(and webservices). In fact, it wasn’t the W3WP.exe itself who made the server hang, but DW20.exe. DW20.exe is Dr.Watson, the Windows Error Reporting tool and was trying to do something when the error was happening on the server.

We’re still investigating the root cause of the issue, but disabling the Windows Error Reporting tool did the trick:

  1. Go to Control Panel.
  2. Click System.
  3. Go to the Advanced tab.
  4. Click Error Reporting.
  5. Click Disable error reporting.

 

disableerrorreporting

Monday, July 4, 2011

Could not execute Powershell script

Last week I had to run a maintenance script on a server. But it gave me the following error:

File cleanup.ps1 cannot be loaded because the execution of scripts is disabled on this system.

Turns out that by default the security setting on the server(the so-called Execution Policy) does not allows us to execute a script. By default, the Execution Policy is set to Restricted. This setting means that you may not run any PS1 script at all.

You can choose between the following Execution Policy levels:

  • Restricted
    This is the default configuration in PowerShell. This setting means that no script can run, regardless of its signature. The only thing that can be run in PowerShell with this setting are individual commands.
  • AllSigned
    This setting does allow scripts to run in PowerShell. The script must have an associated digital signature from a trusted publisher. There will be a prompt before you run the scripts from trusted publishers. This exposes you to running signed, but malicious, scripts.
  • RemoteSigned
    This setting allows scripts to be run, but requires that the script and configuration files that are downloaded from the Internet have an associated digital signature from a trusted publisher. Scripts run from local computer don’t need to be signed. There are no prompts before running the script. Still exposes you to scripts that are signed, yet malicious.
  • Unrestricted
    This is not a suggested setting! This allows unsigned scripts to run, including all scripts and configuration files downloaded from the Internet. This will include files from Outlook and Messenger. The risk here is running scripts without any signature or security.

To change the Execution Policy to Unrestricted, type the following command in Powershell

Set-ExecutionPolicy Unrestricted

To change the Execution Policy to RemoteSigned (to run your own scripts), type the following command in Powershell

Set-ExecutionPolicy RemoteSigned