//此处必须添加,不然不能执行异步回调OnAddPortSuccess方法
<script src="~/scripts/jquery.unobtrusive-ajax.min.js"></script>
<script type="text/javascript">
function OnAddPortSuccess(data) {
var excuteResult = $.parseJSON(data);
alert(excuteResult.toString());
}
</script>
<h2>UserPorts</h2>
@using (Ajax.BeginForm("AddPort", new AjaxOptions()
{
OnSuccess = "OnAddPortSuccess"
}))
{.....}
//由于MVC5 新建项目里不包含jquery.unobtrusive-ajax.js
//
异步上传文件,需要引入<script src="~/scripts/jquery.form.js"></script>