Confused about json post and get when performing a logout action using ASP.MVC3

I want my controller to have a logout. I do not want a new page to appear. I just want to send a message to the controller. Here is what I thought.

But I have some questions.

a) If it is “receive” or “message”, b) To fully understand that in the browser I have to redirect to a new page?

    [HttpPost]
    public JsonResult JsonLogout()
    {
        FormsAuthentication.SignOut();
        return Json(new { success = true });
    }
+3
source share
1 answer

Since you have the HttpPost attribute attached to your action, you will also need to send an ajax request using POST. If you remove this attribute, you can use both POST and GET, and both will work just fine for this application.

, , , , , , ajax , , . , . , , - , .

EDIT: , , ajax . , , , .

!

+3

All Articles