发布到destitution服务器表单后无法将数据发布到Controller内的方法(在本地和开发机器上一切正常)。
返回404错误。
这是我的View Cshtml:
@using (Html.BeginForm("Index", "Account", FormMethod.Post, new { @class = "login-form", @role = "form", @id = "loginform" }))
{
<div class="row">
<div class="large-12 columns">
<input type="text" name="username" />
</div>
</div>
<div class="form-group row">
<div class="large-12 columns">
<input type="password" name="password"/>
</div>
</div>
<div class="form-group row">
<div class="large-12 large-centered columns">
<input type="submit" class="button expand" />
</div>
</div>
}
我的js(ajax和post方法):
var loginAction = function (form) {
$.ajax({
type: 'POST',
url: "/Account/Login",
data: { publicKeyString: SHA($("input[name=password]")},
dataType: 'text',
success: function (response) {
var decodedString = atob(response);
var NetToken = jQuery.parseJSON(decodedString);
var userHash = SHA($("input[name=username]").val());
$("input[name=username]").val(userHash);
var hashpass = HashLoginData(NetToken.PublicKey, $("input[name=password]").val());
$("input[name=password]").val(hashpass);
$("form")[0].submit()
},
});
}
和我的客户经理:
[HttpPost]
public IActionResult Login(string publicKeyString)
{
//somecode
return Content(Convert.ToBase64String(byteText), "text/plain");
}
[HttpPost]
public IActionResult Index(string username, string password)
{
///some code
}
当我用firefox打开网站并点击帖子时,在firebug网络部分它返回404,但是当我使用fiddler并使用composer发布数据时(完全相同的方法)它找到了方法!