# Tuesday, August 10, 2010
Next step in my adventures in deploying to IIS 7

This time I try to access my webservice (MyService.svc).

HTTP Error 404.3 - Not Found

The page you are requesting cannot be served because of the extension of the configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

The IIS handlers window shows no handler for *.svc.

Solution:
Open a command window as administrator
Go to C:\windows\Microsoft.Net\Framework\v3.0\Windows Communication Foundation
Type ServiceModelReg –i

No need to restart, it just works.


UPDATE .Net 4
Open a command window as administrator
Go to %windir%\Microsoft.NET\Framework\v4.0.30319
Type ServiceModelReg –i -c:httpnamespace

posted on Tuesday, August 10, 2010 9:44:57 AM (Romance Daylight Time, UTC+02:00)  #    Comments [0]
When installing a website built on XP/ IIS6 or the built-in Visual Studio Cassini, you put httpHandlers and httpModules in system.web.
On Windows Server 2008/ IIS7, you use system.webServer, with modules and handlers.

If you use the web.config in the standard Ajax-enabled template, this just works.

If not, it doesn't. IIS7 throws an error page.
Description: This application is running in an application pool that uses the Integrated .NET mode. This is the preferred mode for running ASP.NET applications on the current and future version of IIS.

In this mode, the application should not specify ASP.NET module components in the <system.web>/<httpModules> configuration section. Instead, it should use the <system.webServer>/<modules> configuration section to load ASP.NET module components.


The fix is in that Ajax web.config.
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>

It just turns off the validation, allowing system.web/httpModules etc to exist, but ignores them and uses the system.webServer/modules etc version.

Documentation is here.

Yes, this just happened to me. Doh.

posted on Tuesday, August 10, 2010 8:15:08 AM (Romance Daylight Time, UTC+02:00)  #    Comments [0]
# Monday, August 09, 2010
I had a Windows Server 2008 R2 but no IIS. So how to install it? It isn't obvious.

It's in Administrative Tools/ Server Manager / scroll to Roles then Add Roles.
In the roles wizard is a checkbox for Web Server (IIS)
There are various sub options including Common HTTP Features (static content for your images, css), ASP.Net, Security (Windows authentication), Performance (compression), Management Tools (IIS manager)

Here's the details



posted on Monday, August 09, 2010 11:52:17 AM (Romance Daylight Time, UTC+02:00)  #    Comments [0]
# Sunday, August 01, 2010

I was looking at the mess of another programmer's code and realised how much we have individual code styles.

Actually his code wasn't a mess. I turn on code wrapping, he didn't. His nested lambda expressions were suddenly all over the place on my screen, but looked tidy on a wide scrolled screen. I would have introduced more line breaks, splitting parameters onto different lines, but creating more vertical scrolling.

Most colleagues don't write unit tests. That's changing. I've been writing unit tests since .net 1. While I still see people exercising their code by writing console projects or winforms, I've always written unit tests. It's a primitive sort of TDD, at least the part about creating the API in a test. My code is generally old style Asserts against classes and methods, having used vintage NUnit and now MsTest. Lately I try to break up the test into arrange/act/assert sections, and sometimes the BDD language of "Given"/"When"/"Then". Recently company style is to use a custom BDD-type framework on MsTest, but I think the underscores in naming are just plain ugly (the Ruby RSpec style with quoted strings is much nicer and more natural).

I mostly use manual mocks, and whenever I've tried to use a mocking framework I've ripped it out after a while- if you have to write a manual mock it simplifies your API, and that seems neater to me. Recently I've been using Moq for stitching together some components that need use services, and it makes quite heavyweight tests (mostly because we're not allowed to use a DI framework).

Resharper, and more recently CodeRush, are hugely influential in code style- getting the right margin to go green is pretty satisfying, even for very minor things like deleting unused "using" statements. When Resharper 3 suggested using "var" instead of explicit types, I followed them, even though many developers dislike it intensely. The majority opinion seems to be to use "var" with constructors ("var x = new Entity()") but to specify the type returned from methods ("Entity x = Create();"). For the last 2 years or so (when I moved to CodeRush), my code has mostly followed the latter style. When quickly sketching together code, I use var, because I'll be changing methods to use interfaces or base classes, and you don't even have to do rename refactoring.

Resharper has got quite good at suggesting variable names, and usually I take the suggestions. Otherwise some of my variable names can be short - I'm particularly like to use "x" in Linq expressions because brevity makes them much easier to read (as long as methods are short enough):

var result = list.Where(x => x.IsValid); //simple variable names work fine in short methods & linq

ICommonCustomerEntity commonCustomerEntity = commonCustomerEntityCollection.Where(commonCustomerEntity => commonCustomerEntity.IsValid); //ugh

One thing that is characteristic of my code are chunks of specs/user stories (or emails/ work items/ bug reports as applicable) pasted in as internal comments. It doesn't always stay there after I've finished, but it's the first thing I do before coding. It can be nice to see the business logic text immediately above the code (much better than in a Word document, TFS or some task management tracker). It's particularly useful to quote emails when tracking the changing business requirements as you go through acceptance.

posted on Sunday, August 01, 2010 7:48:52 AM (Romance Daylight Time, UTC+02:00)  #    Comments [0]