从Windows Phone App登录Web Api

时间:2014-09-10 06:42:33

标签: asp.net-mvc asp.net-web-api

我使用VS2013中MVC5模板的开箱即用安全性创建了一个WebAPI。

当我尝试使用Post to

获取使用Fiddler的令牌时
https://localhost:44300/token 

并提供内容:username = bob& password = bob& grant_type =密码我将获得一个代币。

在我的WP8.1应用程序中,我有以下功能:

 internal async Task<string> GetBearerToken(string siteUrl, string Username, string Password)
        {
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Clear();
            client.BaseAddress = new Uri(App.BaseUri); 

            var response = client.PostAsync("Token", new StringContent("grant_type=password&username=" + Username + "&password=" + Password, Encoding.UTF8)).Result;

从我的WP8.1应用程序调用此函数时,响应类似于:

StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Content-Length: 0
}

response.RequestMessage.RequestUri读取:

https://localhost:44300/Token

为什么App无法找到此资源? (BTW网络服务器正在运行)

0 个答案:

没有答案