Customizing HealthVault Redirection

The HealthServiceActionPage gives you a very nice mechanism by which you can declaratively define pages handling various HealthVault shell targets. However, folks frequently run in to situation where they need more dynamic way of redirecting and handling shell targets. A simple scenario is if you want to users to come back to the same URL they clicked after being authorized by healthvault shell, e.g. User clicks and returns to instead of going to the default home

Here is a code snippet which illustrates how to extend the HealthServiceActionPage:

using System;
public partial class Redirect : Microsoft.Health.Web.HealthServiceActionPage
    //We don't want this page to require log on because when we sign out,
    //we still want this page to read the WCPage_ActionSignOut key in the
    protected override bool LogOnRequired
            return false;

    public const String ActionQueryStringValue = "actionqs";
    public const String DefaultURL = "";

    protected override void OnActionApplicationAuthorizationSuccessful(string action, 
     string actionQueryString)
        string targetLocation;
        String fullTargetLocation;
        string url = Request.QueryString[ActionQueryStringValue];
        // TODO: Validate that the URL is from home domain
        if (url != null)
            targetLocation = url;
            targetLocation = DefaultURL;
        // we assume that the query string startswith '?'
        fullTargetLocation = targetLocation + actionQueryString;

The magic is in the OnActionApplicationAuthorizationSuccessful method, which allows us to override the authorization successful target. The HealthVault SDK HealthServiceActionPage now provides us several OnAction methods which could be use to override the particular APPAUTH targets.

You can also download this code from MSDN Code here.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.