Welcome to Windows Communication Foundation (WCF)
Top Tasks :

WCF Team Bloggers

Adding CardSpace Support to DasBlog - Part 3 (Browser Script)

So how does one add InfoCard support to a web page? The first think you have to do is add the CardSpace <object> tag to the page, adding some javascript to call the object and get the token, and associated that script with a button on the page. The "UsingCardSpaceWithIE7" sample in the .NET FX 3.0 SDK (the Vista download page has a good overview of what's necessary to get a dev environment going for .NET FX 3.0). Here's what the object tag looks like: < object type ="application/x-informationcard" name =" _ xmlToken "> < param name ="tokenType" value ="urn:oasis:names:tc:SAML:1.0:assertion" /> < param name ="requiredClaims" value ="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier" /> </ object > > You put this somewhere in the <head> of the HTML, so that it's available to the page. Given that dasBlog generates the head portion of the page dynamically, I had to add some code to SharedBasePage.cs:ProcessTemplates() to add this to the page that gets generated. Then, you need to add some script to "dereference" that object tag which causes the CardSpace dialog to pop up, assuming you're running over HTTPS (more on that in a future post). LoginBox.ascx <% @ Control Language ="c#" AutoEventWireup ="false" Codebehind ="LoginBox.ascx.cs" Inherits ="newtelligence.DasBlog.Web.LoginBox" TargetSchema =" http://schemas.microsoft.com/intellisense/ie5 " %> < script language ="javascript"> function GetWCSToken() { var xmltkn=document.getElementById( " _ xmltoken " ); var wcslabel = document.getElementById( "LoginBox_wcstoken" ); wcslabel.value = xmltkn.value ; } </ script > < div class ="signInContainerStyle" id ="login"> < table class ="signInTableStyle"> <!-- omitted some irrelevant stuff --> < tr > < td class ="signInEditCellStyle" colSpan ="2"> < asp : Button ID ="doCardSpaceSignIn" runat ="server" CssClass ="signInButtonStyle" OnClick ="doCardSpaceSignIn_Click" OnClientClick ="BLOCKED SCRIPTGetWCSToken();" Text ='CardSpace Sign-In' Width ="147px" /> &nbsp;&nbsp; < asp : Button ID ="doRegisterCardSpace" runat ="server" CssClass ="signInButtonStyle" OnClick ="doRegisterCardSpace_Click" OnClientClick ="BLOCKED SCRIPTGetWCSToken();" Text ='Register CardSpace' Read More...
Published Sunday, January 07, 2007 8:54 PM by OhmBlog

Comments

No Comments
Anonymous comments are disabled

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us