Previous month:
September 2012
Next month:
November 2012

October 2012

You thought identity management is ‘done’? Think twice: thinktecture IdentityServer v2 Beta is here

The Beta version of our open source IdentityServer STS has been released today:

http://leastprivilege.com/2012/10/12/thinktecture-identityserver-v2-beta/

 

Check out the short intro video to get a quick start:

http://leastprivilege.com/2012/10/12/setup-thinktecture-identityserver-v2-in-7-minutes/

 

Any feedback is always welcome and highly appreciated! Dominick and Brock (and a little bit of myself will hang out there…)
https://github.com/thinktecture/Thinktecture.IdentityServer.v2/issues

 

Thanks.


Bug in ASP.NET 4.0 routing: Web API Url.Link may return null

The other day I was building an integration layer for native HTML5/JS-based mobile apps with Windows Azure’s ACS. For that I needed to craft a redirect URL in one of the action in a controller called AcsController.

This is my route setup for Web API:

   1:  config.Routes.MapHttpRoute(
   2:      name: "ACSApi",
   3:      routeTemplate: "api/acs/{action}/{ns}",
   4:      defaults: new { controller = "Acs", ns = RouteParameter.Optional, 
   5:          realm = RouteParameter.Optional }
   6:  );
   7:   
   8:  config.Routes.MapHttpRoute(
   9:      name: "DefaultApi",
  10:      routeTemplate: "api/{controller}/{id}",
  11:      defaults: new { id = RouteParameter.Optional }
  12:  );

 

Then in the controller action I try to use Url.Link to build a redirect URL:

var redirectUrl = Url.Link("ACSApi", new { controller = "Acs", action = "Noop" });

On various systems running .NET 4.0 this call returned null. Including Windows Azure Web Sites. On installations with .NET 4.5 all was fine. After several emails back and forth with the Web API team in Redmond it turned out that there is a bug in .NET 4.0.

The issue is in ASP.NET Routing with routes that have optional route values followed by a slash. This issue has been fixed in .NET 4.5. But there is a workaround for 4.0 like this:

   1:  config.Routes.MapHttpRoute(
   2:      name: "ACSApi",
   3:      routeTemplate: "api/acs/{action}/{ns}",
   4:      defaults: new { controller = "Acs", ns = RouteParameter.Optional, 
   5:          realm = RouteParameter.Optional }
   6:  );
   7:   
   8:  config.Routes.MapHttpRoute(
   9:      name: "ACSApi2",
  10:      routeTemplate: "api/acs/{action}/{ns}/{realm}",
  11:      defaults: new { controller = "Acs", realm = RouteParameter.Optional }
  12:  );
  13:   
  14:  config.Routes.MapHttpRoute(
  15:      name: "DefaultApi",
  16:      routeTemplate: "api/{controller}/{id}",
  17:      defaults: new { id = RouteParameter.Optional }
  18:  );

 

Hope this helps.