0

We may never know why Microsoft decided to limit developers by making HealthVault applications constrained to a single web/app.config entry for a HealthVault application. However I need to be able to make 2 (or more) HealthVault ApplicationID’s work with one ASP.NET website? I’m looking for an effective and reliable way to do this.

I won’t go into the details of the reasoning behind 2 different HealthVault applications, but other than to say we need it to work. I still cannot login correctly with MSDN Forums (think infinite redirection sign in loop) so I am hoping for a post here that will help me.

I did contact a HealthVault developer on how to achieve this however the developer gave a suggestion that I don’t believe would be reliable (if I’m wrong let me know).

The developer’s suggestion was to do the following in code when you needed to connect to HealthVault, but prior to connecting:

ConfigurationSettings.AppSettings[“ApplicationId”] = “[YOUR APP ID]”;

The problem is that this is a static property and I do see this as an issue as our web application will have different users accessing both HealthVault applications at the same time. Does anyone have any suggestions to make 2 (or more) HealthVault ApplicationID’s work with one ASP.NET website? I’m looking for an effective and reliable way to do this.

4

1 回答 1

0

有一种方法可以在运行时动态切换应用程序 ID。必须创建两个应用程序,必须安装两个证书。几件事情要记住。对于每个经过身份验证的连接,用户将被授予一个令牌(又名 wctoken)。

当您的 redirect.aspx 页面(假设您的重定向页面继承自HealthServiceActionPage

这意味着每次切换应用程序时,您必须重定向用户返回具有新应用 ID 的 Live ID 以接收新令牌。

这是用户可以动态更改设置的代码示例:

public class ConfigurationManager : HealthWebApplicationConfiguration
{
    private string appid;
    public ConfigurationManager(string appid)
    {
        this.appid = appid;
    }
    public override Guid ApplicationId
    {
        get
        {
           return AppManager.Current.GetCurrentAppId(this.appid);
        }
    }
}

public class AppManager
{
    private static readonly Object lck = new Object();

    public Guid? App;

    public static AppManager Current
    {
        get
        {
            AppManager mgr = null;

            if (_current == null)
            {
                lock (lck)
                {
                    mgr = new AppManager();
                }
            }

            return mgr;
        }
    }

    private static AppManager _current;

    public Guid GetCurrentAppId(string id)
    {
        return new Guid(id);
    }
}

用法:

ConfigurationManager cm = new ConfigurationManager(your-app-id-here);
HealthWebApplicationConfiguration.Current = cm;
于 2011-10-27T04:46:12.723 回答