呼叫控制器

时间:2019-05-31 08:06:21

标签: .net-core controller

这是我用于调用控制器动作的代码,但是它不起作用。 我在控制器中放置了断点,但它从未到达终点。

用于调用控制器操作的代码:

function Log() {

        var UserName = $('#korisnik').val();
        var Password = $('#lozinka').val();


        $.ajax({
            url:'Members/LoginUser',
            data: { username: UserName, password: Password },
            type: "post",
            success: function (data) {               
                        window.location.href = "Home/Index";
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr.responseText);
                alert(thrownError.responseText);
            }
           });      
        }

控制器中的代码:

 public class MembersController : Controller
    {

    bool member = false;

    Members members = new Members();

    [Route("Index")]
    public IActionResult Index()
    {

            return View("MembersLogin");

    }

            [HttpPost]
            public IActionResult LoginUser(string username,string password)
            {

                var result = members.GetMember(username, password);

                ViewBag.UserName = username;

                return View();     
            }
     }

我在var result = ...上设置了断点

0 个答案:

没有答案