Friday, December 9, 2011

WCF Web API security in a domain

I've been building REST services using WCF Web API for use in an intranet. Upon deployment from my desktop to a server I started experiencing the error below even though the hosting application, ASP.NET MVC 3, was successfully using Windows authentication.

System.NotSupportedException: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

A Google search shows that this isn't a novel situation, but I couldn't get the configuration and incantation right for Web API. Luckily, after a couple of hours of researching and fiddling with the web.config, I came across this post that revealed the solution to me.

When registering the service route:
var config = new HttpConfiguration();
   config.Security = (u, s) => {
      s.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
      s.Mode = HttpBindingSecurityMode.TransportCredentialOnly;
   };

   routes.MapServiceRoute<YourType>("YourRoutePrefix", config);

I hope that this post saves someone some time.

Tuesday, December 6, 2011

MvcBuildViews in a CI environment

This post isn't going to break any new ground in the world of computer science, but I still wanted to say a few words about the importance of using MvcBuildViews in your continuous integration environment.

My team had just finished a quick and slightly dirty ASP.NET MVC 3 project. The three of us rapidly created a very usable internal departmental financial application with two of the members of the team being ASP.NET MVC neophytes. A lot of learning occurred during development, both about the basics of HTTP and client scripting as well as Visual Studio's ASP.NET MVC 3 tooling.

I was finishing off numerous TODO's toward the end of the project when I entered "/p:MvcBuildViews=true" in the MSBuild arguments section of the Team Build process tab. The build crashed immediately due to nonexistent namespace issues. It seems that a family of CRUD Views had been created at some point that used a Model that no longer existed. Apparently the plan had been to go back and clean up dead code, but there was never any follow-up due to other priorities. The dead Views certainly weren't hurting anything. Also, a user could only access them if they somehow typed in the correct URL, a near impossible eventuality. However, I abhor dead code and extra files in a project. It not only distorts the size and complexity of a project but also increases the size of the deployment.

Using MvcBuildViews helped me remove four Views from our final deployment package. That's a trivial amount for large, enterprise projects. However, for a small department application likes ours, that's 20% of the Views. So not only are there now dramatically fewer Views to manage, the steepness of the learning curve for new developers is reduced.

Thursday, December 1, 2011

Anyone looking for work in Kathmandu?

I certainly have never been contacted about such an exotic job opportunity!


On November 16, 2011 at 1:00 AM Fine Tuners  wrote:

Dear Sir/Madam,
 
We have explored your company as one of the best ever growing software development company.  This is what we are interested in. 
FineTuners is a Kathmandu based software development and web development company. Our Outsourcing firm is  located at the heart of Nepal, Kathmandu. Nepal is well known for its culture, natural resources and on the top for Mount Everest, the highest pick of the world.
At present we are mainly focusing on the following areas as per the need of ever growing market:
·        Web services( Slicing/ Development/ full shop)
·        Web applications from simple web portals to the dynamic ecommerce sites)
We are a highly experienced team of intellectuals who are versatile in different development tools. Actually we are providing with different kinds of services, based on your requirement which you can choose. Else you can let us know the brief requirements of your projects such as technology, and services you require.
If this is the interest of yours, we are always standby to assist. You can explore us more via: www.fintuners.com . We are here to provide you with unlimited opportunities.
 
We offer you a trail project. If you like the work, then you pay us else you don’t have to pay for what is done. This is the best deal we can offer you to build up the trust.
     
     
    -- 
     
    -- 
    Best Regards,
    Sachit Pokhrel
    FineTuners
    www.fintuners.com
    skype: sunilpokharel1