• <small id='ZOafs'></small><noframes id='ZOafs'>

  • <legend id='ZOafs'><style id='ZOafs'><dir id='ZOafs'><q id='ZOafs'></q></dir></style></legend>
  • <i id='ZOafs'><tr id='ZOafs'><dt id='ZOafs'><q id='ZOafs'><span id='ZOafs'><b id='ZOafs'><form id='ZOafs'><ins id='ZOafs'></ins><ul id='ZOafs'></ul><sub id='ZOafs'></sub></form><legend id='ZOafs'></legend><bdo id='ZOafs'><pre id='ZOafs'><center id='ZOafs'></center></pre></bdo></b><th id='ZOafs'></th></span></q></dt></tr></i><div id='ZOafs'><tfoot id='ZOafs'></tfoot><dl id='ZOafs'><fieldset id='ZOafs'></fieldset></dl></div>
      <bdo id='ZOafs'></bdo><ul id='ZOafs'></ul>

    <tfoot id='ZOafs'></tfoot>

      1. ASP.NET 5/MVC 6 Ajax 将模型发布到控制器

        时间:2023-07-11

          <small id='2vTLx'></small><noframes id='2vTLx'>

            <bdo id='2vTLx'></bdo><ul id='2vTLx'></ul>
              <legend id='2vTLx'><style id='2vTLx'><dir id='2vTLx'><q id='2vTLx'></q></dir></style></legend>
                <tbody id='2vTLx'></tbody>

              1. <tfoot id='2vTLx'></tfoot>
                1. <i id='2vTLx'><tr id='2vTLx'><dt id='2vTLx'><q id='2vTLx'><span id='2vTLx'><b id='2vTLx'><form id='2vTLx'><ins id='2vTLx'></ins><ul id='2vTLx'></ul><sub id='2vTLx'></sub></form><legend id='2vTLx'></legend><bdo id='2vTLx'><pre id='2vTLx'><center id='2vTLx'></center></pre></bdo></b><th id='2vTLx'></th></span></q></dt></tr></i><div id='2vTLx'><tfoot id='2vTLx'></tfoot><dl id='2vTLx'><fieldset id='2vTLx'></fieldset></dl></div>
                  本文介绍了ASP.NET 5/MVC 6 Ajax 将模型发布到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的 ASP.NET 5 MVC 6 应用程序中,我想使用 Ajax 将一些数据发布到我的控制器.我已经用 ASP.NET MVC 5 完成了这项工作,并在一个空白的 ASP.NET MVC 5 项目中测试了完全相同的代码并且它可以工作,但是对于新版本我不能,我不知道为什么.通过 Ajax 调用,我可以转到控制器,创建模型但字段为空(或布尔值为假).这是我的代码:

                  In my ASP.NET 5 MVC 6 application, I want to post with Ajax some data to my controller. I already done this with ASP.NET MVC 5 and I tested the exact same code in an blank ASP.NET MVC 5 project and it worked, but with the new version I can't and I don't know why. With the Ajax call, I can go to the controller, the model is created but the fields are null (or false for the boolean). Here is my code :

                  script.js:

                  var data = {
                              model: {
                                  UserName: 'Test',
                                  Password: 'Test',
                                  RememberMe: true
                              }
                          };
                  
                          $.ajax({
                              type: "POST",
                              url: "/Account/Login/",
                              data: JSON.stringify(data),
                              contentType: "application/json; charset=utf-8",
                              dataType: "json",
                              success: function (msg) {
                                  // Do something interesting here.
                              }
                          });
                  

                  AccountController.cs:

                  AccountController.cs :

                  [HttpPost]
                      public JsonResult Login(LoginViewModel model)
                      {
                          if (ModelState.IsValid)
                          {
                              //var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);
                              //if (result.Succeeded)
                              //{
                              //     //return RedirectToLocal(returnUrl);
                              /
                  • <legend id='1iPE6'><style id='1iPE6'><dir id='1iPE6'><q id='1iPE6'></q></dir></style></legend>
                      <i id='1iPE6'><tr id='1iPE6'><dt id='1iPE6'><q id='1iPE6'><span id='1iPE6'><b id='1iPE6'><form id='1iPE6'><ins id='1iPE6'></ins><ul id='1iPE6'></ul><sub id='1iPE6'></sub></form><legend id='1iPE6'></legend><bdo id='1iPE6'><pre id='1iPE6'><center id='1iPE6'></center></pre></bdo></b><th id='1iPE6'></th></span></q></dt></tr></i><div id='1iPE6'><tfoot id='1iPE6'></tfoot><dl id='1iPE6'><fieldset id='1iPE6'></fieldset></dl></div>
                      1. <tfoot id='1iPE6'></tfoot>

                          <tbody id='1iPE6'></tbody>
                        • <bdo id='1iPE6'></bdo><ul id='1iPE6'></ul>

                          <small id='1iPE6'></small><noframes id='1iPE6'>