How to pass model from view to controller when click button in MVC?

后端 未结 2 709
梦如初夏
梦如初夏 2020-12-12 06:58

Index - View

@model SendAFaxWeb.Models.Send
//view start here

    

Test Upload File

2条回答
  •  爱一瞬间的悲伤
    2020-12-12 07:24

    You have implemented cross origin security like : @Html.AntiForgeryToken(). So you have to pass that value as parameter in your AJAX call as below.

    AJAX:

    data:{__RequestVerificationToken:$('[name=__RequestVerificationToken]').val();}
    

    Also you have to add attribute in controller.

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Send(Send contact)
    

提交回复
热议问题