这段时间使用BootStrap+Asp.net Mvc5开发项目,Ajax.ActionLink遇到一个重复提交的BUG,代码如下:

 @model IList<WFModel.WF_Temp>
@{
Layout = null;
} <!DOCTYPE html> <html>
<head>
<meta name="viewport" content="width=device-width" />
<title>工作流模板列表</title>
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<script src="~/Scripts/jquery-2.1.1.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
</head>
<body>
@Ajax.ActionLink("添加工作流模板", "AddTemp", "WFTemp", new AjaxOptions()
{
HttpMethod="Get"
},new
{
@class = "btn btn-primary",
data_toggle="modal",
data_target="#myModal"
})
<br/>
<div class="table-responsive">
<table class="table">
<tr>
<th>模板名称</th>
<th>提交时间</th>
<th>模板的描述</th>
<th>模板提交人</th>
</tr>
<tbody>
@{
foreach (var item in Model)
{
<tr>
<td>@item.TempName</td>
</tr>
}
}
</tbody>
</table>
</div>
</body>
</html>
<!-- Button trigger modal -->
@*<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>*@ <!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">添加模板</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary">保存</button>
</div>
</div>
</div>
</div>

如何解决呢,HttpMethod="Get"变成"Post"就可以了

04-27 16:34