DBPedias

Your Database Knowledge Community

Christian Weyer's Blog

  1. Measuring performance of your HTTP-based .NET applications: Performance Counters for HttpWebRequest

    Just found this and thought to share it with you: Network Class Library Team (System.Net): New Performance Counters for HttpWebRequest

     

    Each of the seven green circles represents one of the six performance counters (there are two ‘5’ items because 5 is the average lifetime, and there are two code paths that will affect that counter).

     

    Note: Be aware that ‘new’ means new in .NET 4.0 (the blog post is from Aug 2009).

  2. Slides for my sessions at DevWeek 2012

    And here we go – as promised to all of you nice people attending one of my sessions last week in London.

     

    If you have questions, please feel free to send my an email!

    See you next year at DevWeek.

  3. Light-weight web-based architectures: Web APIs Services (or: ASP.NET vs. WCF?) a personal view

    As much as I like WCF (and as much as I made money with it in the past years) – I think it is now time to re-think some approaches and some architectural ideas. What is ahead of a lot of us is what I call ‘light-weight architectures for reach’.

    Just to give you some scope: I am one of the original Digerati board members of Indigo (WCF). Some people say I know WCF inside-out - I have given several dozens of introductions to WCF in seminars, conference and user group sessions world-wide and did numberless consulting gigs in Europe with WCF (and no, I did not really find time to write a book – besides a chapter here).

    OK, so here goes...

    There is currently a shift - or rather a new focus - in distributed application architecture. And no, I am not going to call it REST and I am not saying it is the one and only true thing from now on. But we have new drivers like application mash-ups, mobile devices and cloud computing which force us to move away from the good old feature-rich (and somehow heavy-weight) SOAP-based approaches. This development and this need is non-discussable and undeniable. One possible solution to these new needs is the use of light-weight Web APIs (which can be evolved into a REST-ful API or be used 'just' in an RPC-ish way).

    So, which technology framework should we as .NET developers choose to build Web APIs? One choice is to leverage WCF's WebHttp model. After working with it for some years I quickly noticed a number of shortcomings (testability/mockability, serializers, ...) and wished that Redmond would come up with something better. *Of course* it had to be WCF, it had to be part of the overall "let's abstract away communication 'details'". And so it happened that they announced WCF Web API (and I was lucky enough to be part of the advisory board, again). All was fine in my world. It seemed.

    Fine until I again realized that it has shortcomings when building some more flexible and advanced Web APIs. But this time it was actually the fact that the limitations were in WCF itself. The 'SAOP message' model of WCF just does not fit at all into this world. Everything the team tried to accomplish and to provide features for a web-based paradigm was just trying to put the round into the rectangle (and vice versa). For a web-based base framework maybe WCF is not the right choice.
    And it turned out that there is a very good framework that can deal with the web and HTTP in a fantastic way. So, the decision to build a .NET web API framework on ASP.NET (and ASP.NET MVC, to be more precise) was somehow natural.
    I personally had one very strong wish - something I have learned in the past years is invaluable for a lot of our customers... self-hosting! So, the advisors pushed hard to get self-hosting, and here it is: we can perfectly build our own host processes and host the exact same Web API implementation either there or in IIS/ASP.NET.

    Today, I am quite happy with what happened. The only issue I still have is the name: I would definitely have not called it ASP.NET Web API, but rather .NET Web API. If you are working in my geographical area then you may understand why.

    Anyway... talking a bit about application architecture (.NET server-side):
    I would build a WCF service and an ASP.NET Web API (at least with the RPC-ish approach) as a facade only - the actual logic (business logic or data/resource access) is hidden beyond that facade. With this simple pattern it is no problem to have both WCF SOAP services and ASP.NET Web APIs sitting right next to each other happily ever after. I am doing it all the time. And you are then actually in the power to leverage the full power of each framework - get the most out of SOAP/XSD/WSDL/WS-* and the best out of web APIs/REST/whatever.

    Fact is, I am using Web APIs quite a lot these days as we are building cloud-based systems in an increasing number and also cross-device mobile apps.

    My 2 services cents.
    Flame away.

  4. Slides von der BASTA! Spring 2012

    Vielen Dank an alle, die in meine Sessions (inklusive der Keynote) und die Sessions der anderen thinktecture-Experten gekommen sind – war mal wieder eine prima BASTA!

    Bis zum nächsten Mal!

  5. Learn claims-based identity from the master of claims, WIF and ACS

    thinktecture’s security expert Dominick Baier spends numerous hours every month answering questions about WIF and identity in general. Recently he put together a two day training course about WIF that covers everything he thinks is important.

    The course includes extensive lab material where you take standard application and apply all kinds of claims and federation techniques and technologies like WS-Federation, WS-Trust, session management, delegation, home realm discovery, multiple identity providers, Access Control Service, REST, SWT and OAuth. The lab also includes the latest version of the thinktecture IdentityServer and you will learn how to use and customize it.

    If you are looking for an open enrollment style of training, have a look here or here.
    Or contact Dominick directly.

     

    The course outline:

    Day 1
    Intro to Claims-based Identity & the Windows Identity Foundation
    WIF introduces important concepts like conversion of security tokens and credentials to claims, claims transformation and claims-based authorization. In this module you will learn the basics of the WIF programming model and how WIF integrates into existing .NET code.

    Externalizing Authentication for Web Applications
    WIF includes support for the WS-Federation protocol. This protocol allows separating business and authentication logic into separate (distributed) applications. The authentication part is called identity provider or in more general terms - a security token service. This module looks at this scenario both from an application and identity provider point of view and walks you through the necessary concepts to centralize application login logic both using a standard product like Active Directory Federation Services as well as a custom token service using WIF’s API support.

    Externalizing Authentication for SOAP Services
    One big benefit of WIF is that it unifies the security programming model for ASP.NET and WCF. In the spirit of the preceding modules, we will have a look at how WIF integrates into the (SOAP) web service world. You will learn how to separate authentication into a separate service using the WS-Trust protocol and how WIF can simplify the WCF security model and extensibility API.

    Day 2
    Advanced Topics:  Security Token Service Architecture, Delegation and Federation
    The preceding modules covered the 80/20 cases of WIF in combination with ASP.NET and WCF. In many scenarios this is just the tip of the iceberg. Especially when two business partners decide to federate, you usually have to deal with multiple token services and their implications in application design. Identity delegation is a feature that allows transporting the client identity over a chain of service invocations to make authorization decisions over multiple hops. In addition you will learn about the principal architecture of a STS, how to customize the one that comes with this training course, as well as how to build your own.

    Outsourcing Authentication:  Windows Azure & the Azure AppFabric Access Control Service
    Microsoft provides a multi-tenant security token service as part of the Azure platform cloud offering. This is an interesting product because it allows to outsource vital infrastructure services to a managed environment that guarantees uptime and scalability. Another advantage of the Access Control Service is, that it allows easy integration of both the “enterprise” protocols like WS-* as well as “web identities” like LiveID, Google or Facebook into your applications. ACS acts as a protocol bridge in this case where the application developer doesn’t need to implement all these protocols, but simply uses a service to make it happen.

    Claims & Federation for the Web and Mobile World
    Also the web & mobile world moves to a token and claims-based model. While the mechanics are almost identical, other protocols and token types are used to achieve better HTTP (REST) and JavaScript integration for in-browser applications and small footprint devices. Also patterns like how to allow third party applications to work with your data without having to disclose your credentials are important concepts in these application types. The nice thing about WIF and its powerful base APIs and abstractions is that it can shield application logic from these details while you can focus on implementing the actual application.

  6. Cross-device/cross-location Pub-Sub (part 3): Using Windows Azure Service Bus Topics Subscriptions in Android with Mono for Android

    And here we go with the final piece of blogging around the Windows Azure Service Bus and its cross-device, cross-location pub/sub features.

    There have already been two articles about this topic (pun intended Winking smile)


    Today I have built a very simple Android app with MonoDroid (aka Mono for Android) in C#. The code is essentially the same as for the iOS demo shown earlier (with MonoTouch), I just used Monodroid.Dialog to programmatically wire up the UI.

    image

    This is the entire code for the app:

       1:  [Activity(Label = "DroidServiceBusSubscriber",
       2:    MainLauncher = true, Icon = "@drawable/icon")]
       3:  public class MainActivity : Activity
       4:  {
       5:      private ListView lv;
       6:      private DialogAdapter da;
       7:      private RootElement menu;
       8:      private Section messages;
       9:      private BrokeredMessaging broker;
      10:      private string sbNamespace = "YOUR_SB_NS";
      11:      private string issuerName = "owner";
      12:      private string issuerSecret = "YOUR_OWNER_ISSUERKEY";
      13:      private string topicName = "newstopic";
      14:      private string subscriptionName = "androidsubscription";
      15:   
      16:      protected override void OnCreate(Bundle bundle)
      17:      {
      18:          base.OnCreate(bundle);
      19:   
      20:          InitBroker();
      21:          SetupUI();
      22:          RegisterMessagesHandler();
      23:      }
      24:   
      25:      private void InitBroker()
      26:      {
      27:          broker = new BrokeredMessaging(sbNamespace);
      28:          broker.GetToken(issuerName, issuerSecret);
      29:      }
      30:   
      31:      private void SetupUI()
      32:      {
      33:          messages = new Section("Messages");
      34:          menu = new RootElement("Service Bus Subscriber")
      35:          {
      36:              messages
      37:          };
      38:   
      39:          da = new DialogAdapter(this, menu);
      40:          lv = new ListView(this) { Adapter = da };
      41:              
      42:          SetContentView(lv);            
      43:      }
      44:   
      45:      private void RegisterMessagesHandler()
      46:      {
      47:          Task.Factory.StartNew(() =>
      48:          {
      49:              while (true)
      50:              {
      51:                  try
      52:                  {
      53:   
      54:                      var message = broker.ReceiveAndDeleteMessage(topicName + 
      55:                        "/Subscriptions/" + subscriptionName);
      56:   
      57:                      if (!String.IsNullOrWhiteSpace(message))
      58:                      {
      59:                          RunOnUiThread(delegate
      60:                          {
      61:                              messages.Elements.Add(new StringElement(message));
      62:                              da.NotifyDataSetChanged();
      63:                          });
      64:                      }
      65:   
      66:                  }
      67:                  catch (Exception ex)
      68:                  {
      69:                      Console.WriteLine(ex);
      70:                  }
      71:              }
      72:          });
      73:      }
      74:  }

     

    And the ServiceBusBrokeredMessaging class is exactly copied and pasted from the MonoTouch project to the VS 2010 project for MonoDroid.

    Here is the client app solution (you will need Mono for Android for Visual Studio):


    Hope this helps.

  7. Hosting a public web site (ASP.NET) and an internal services site (WCF) in one Windows Azure web role sample code

    Alright. I got some emails asking for the actual project and code for the blog post over here.

    Imagine you want to host some (Web) services in an IIS web site inside your Windows Azure compute web role. In addition, you also want to host your web application/portal in another web site in Full IIS in the *same* web role. […]

    Here is a working solution (based on Windows Azure Tools for VS 2010 1.6).
    Hope this helps.

  8. Cross-device/cross-location Pub-Sub (part 2): Using Windows Azure Service Bus Topics Subscriptions in Windows Phone (7.1)

    In the previous post I showed how to use MonoTouch and C# on iOS devices to subscribe to the Windows Azure Service Bus’s topics and subscriptions features.

    This time it is a Windows Phone (Mango) client app.

    The sending / publishing application is still the same Console application from the last post:

    image

    And the nice part about the WP app is that Kellabyte already did the major work for wrapping the Service Bus queues, topics, and subscriptions REST API (also check out her awesome Continuous Client demo which uses the Service Bus). Smile

    With her code in place the actual subscribing inside my WP app to the messages in my Service Bus subscriptions is a piece of cake:

       1:  public MainPage()
       2:  {
       3:      InitializeComponent();
       4:   
       5:      InitBroker();
       6:  }
       7:   
       8:  private void InitBroker()
       9:  {
      10:      token = new Token(sbNamespace, issuerName, issuerSecret);
      11:      token.Requested += new EventHandler<TokenEventArgs>(token_Requested);
      12:      token.Request();
      13:  }
      14:   
      15:  private void token_Requested(object sender, TokenEventArgs e)
      16:  {
      17:      topic = new Topic(token, topicName);
      18:   
      19:      RegisterMessagesHandler();
      20:  }
      21:   
      22:  private void RegisterMessagesHandler()
      23:  {
      24:      subscription = new Subscription(topic, subscriptionName);
      25:      subscription.MessageRecieved += 
      26:                    new EventHandler<SubscriptionMessageEventArgs>(
      27:                      subscription_MessageRecieved);
      28:      subscription.ReceiveMessage();
      29:  }
      30:   
      31:  private void subscription_MessageRecieved(object sender, SubscriptionMessageEventArgs e)
      32:  {
      33:      var message = e.Message;
      34:   
      35:      try
      36:      {
      37:          if (!String.IsNullOrWhiteSpace(message))
      38:          {
      39:              Dispatcher.BeginInvoke(() =>
      40:              {
      41:                  mainContentPanel.RowDefinitions.Add(
      42:                      new RowDefinition { Height = new GridLength(35) });
      43:   
      44:                  var pos = mainContentPanel.RowDefinitions.Count - 1;
      45:   
      46:                  var txt = new TextBlock();
      47:                  txt.Text = message;
      48:                  mainContentPanel.Children.Add(txt);
      49:                  Grid.SetColumn(txt, 0);
      50:                  Grid.SetRow(txt, pos);
      51:              });
      52:          }
      53:      }
      54:      catch (Exception ex)
      55:      {
      56:          Console.WriteLine(ex);
      57:      }
      58:   
      59:      subscription.ReceiveMessage();
      60:  }


    And the (again) super spectacular result is that all the messages are being sucked from my subscription and displayed on the phone:

    image

    Voila. Sorry – not so exciting as last time. Anyway, here is the download:


    Hope this helps.

  1. 1
  2. Next ›
  3. Last »