Asp.net Windows Phone 7.1(Mango)上的表单身份验证?

Asp.net Windows Phone 7.1(Mango)上的表单身份验证?,asp.net,asp.net-membership,forms-authentication,windows-phone-7.1,windows-phone-7,Asp.net,Asp.net Membership,Forms Authentication,Windows Phone 7.1,Windows Phone 7,我正在尝试使用WP7(Mango)emulator和forms身份验证登录我的works网站。(最终创建一个WP7应用程序,让您可以在此网站上查看某些内容) 站点网络配置包含以下内容: <system.web.extensions> <scripting> <webServices> <authenticationService enabled="true" requireSSL="false"/> </w

我正在尝试使用WP7(Mango)emulator和forms身份验证登录我的works网站。(最终创建一个WP7应用程序,让您可以在此网站上查看某些内容)

站点网络配置包含以下内容:

  <system.web.extensions>
<scripting>
    <webServices>
        <authenticationService enabled="true" requireSSL="false"/>
    </webServices> 
</scripting>
我不能把这段代码复制粘贴到WindowsPhone7.1(Mango)应用程序中,因为网络代码稍有不同-例如..一切都是在WP7或类似的程序中异步完成的

myWebRequest.GetResponse()
myWebRequest.BeginGetResponse()
不再管用了,我得做点什么

myWebRequest.GetResponse()
myWebRequest.BeginGetResponse()
如果有人在WP7中有任何使用forms auth进行身份验证的工作代码示例,那就太好了


非常感谢

查看此http类:

下面的代码应该可以做到这一点:

private void OnButtonClick(object sender, RoutedEventArgs e)
{
    const string username = "user";
    const string password = "password";
    const string loginServiceAddress = "http://www.server.com/Services/AuthenticationService.svc";

    var text = string.Format("{{ \"userName\": \"{0}\", \"password\": \"{1}\", \"createPersistentCookie\":false}}", 
        username, password);

    var request = new HttpPostRequest(loginServiceAddress);
    request.RawData = Encoding.UTF8.GetBytes(text);
    request.ContentType = "application/json";
    Http.Post(request, AuthenticationCompleted);
}

private void AuthenticationCompleted(HttpResponse authResponse)
{
    const string serviceAddress = "http://www.server.com";
    if (authResponse.Successful)
    {
        var sessionCookie = authResponse.Cookies.Single(c => c.Name == "SessionId");
        var request = new HttpGetRequest(serviceAddress);
        request.Cookies.Add(new Cookie("SessionId", sessionCookie.Value));
        Http.Get(request, OperationCallCompleted);
    }
}

private void OperationCallCompleted(HttpResponse response)
{
    if (response.Successful)
    {
        // TODO: do your parsing
        var responseText = response.Response;

        Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
            // TODO: set data to binding or directly to user control (in UI thread)
        });
    }
}

我无法使用代码,编译错误-某些类缺少HttpUtilityExtensions似乎是罪魁祸首-我会尝试解决它,但很抱歉,HttpUtilityExtensions可以在以下位置找到:编辑: