title: Asp.net mvc connect to webApi by httpClient
body: <p>I have mvc application and webApi application. I need sign in in asp.net mvc through webApi. When i use this method:</p>
  
  <pre><code>public static string GetToken(LoginModelView login)
          {
              var pairs = new List&lt;KeyValuePair&lt;string, string&gt;&gt;
                          {
                              new KeyValuePair&lt;string, string&gt;( "grant_type", "password" ),
                              new KeyValuePair&lt;string, string&gt;( "username", login.Login ),
                              new KeyValuePair&lt;string, string&gt; ( "Password", login.Password )
                          };
              var content = new FormUrlEncodedContent(pairs);
              using (var client = new HttpClient())
              {
                  var response =
                      client.PostAsync(URL + "/Token", content).Result;
                  var responseJson = response.Content.ReadAsStringAsync().Result;
                  var dictionaryToken = JsonConvert.DeserializeObject&lt;Dictionary&lt;string,string&gt;&gt;(responseJson);
                  string token = dictionaryToken["access_token"];
                  return token;
              }
          }
  </code></pre>
  
  <p>My mvc don't bind model from view.
  Action methods</p>
  
  <pre><code>[HttpGet]
          public ActionResult SignIn()
          {
              var login = new LoginModelView();
              return View("SignIn",login);
          }
  
          [HttpPost]
          public ActionResult SignIn(LoginModelView login)
          {
              string token = DirService.GetToken(login);
  
              Session["token"] = token;
  
              return RedirectToAction("success");
          }
  </code></pre>
  
  <p>It's model</p>
  
  <pre><code>public class LoginModelView
      {
          public string Login { get; set; }
  
          public string Password { get; set; }
      }
  </code></pre>
  
  <p>It's my view</p>
  
  <pre><code>@model AdminTool.Models.LoginModelView
      @using (Html.BeginForm())
      {
          @Html.AntiForgeryToken()
  
          &lt;div class="form-horizontal"&gt;
              &lt;h4&gt;LoginModelView&lt;/h4&gt;
              &lt;hr /&gt;
              @Html.ValidationSummary(true, "", new { @class = "text-danger" })
              &lt;div class="form-group"&gt;
                  @Html.LabelFor(model =&gt; model.Login, htmlAttributes: new { @class = "control-label col-md-2" })
                  &lt;div class="col-md-10"&gt;
                      @Html.EditorFor(model =&gt; model.Login, new { htmlAttributes = new { @class = "form-control" } })
                      @Html.ValidationMessageFor(model =&gt; model.Login, "", new { @class = "text-danger" })
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  @Html.LabelFor(model =&gt; model.Password, htmlAttributes: new { @class = "control-label col-md-2" })
                  &lt;div class="col-md-10"&gt;
                      @Html.EditorFor(model =&gt; model.Password, new { htmlAttributes = new { @class = "form-control" } })
                      @Html.ValidationMessageFor(model =&gt; model.Password, "", new { @class = "text-danger" })
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="form-group"&gt;
                  &lt;div class="col-md-offset-2 col-md-10"&gt;
                      &lt;input type="submit" value="Login" class="btn btn-default" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      }
  </code></pre>
  
  <p>when i don't use that method, everything is ok.
  The same code works in another application.
  Somebody can help me, please..</p>