"비밀번호 찾기"링크가있는 로그인 양식이 있습니다.asp.net에서 동일한 컨트롤러의 httpPost와 ActionLink MVC 5
@Html.ActionLink("Forgot Password", "ForgotPassword", "Login", Model , new { @onclick = "return ValidateUsername();" })
내가 필요로하는 POST 대신 GET로 보내는 것입니다 : 로그인에 링크 좀 다른 행동을 부르고을 "비밀번호 분실"에있는 동안 나는 다른 작업을 호출하고 제출합니다.
내가 가지고있는 ASP.NET WebForm 솔루션은 거의 완전히 ASP.NET MVC로 변환되었습니다. 한 곳에서 LinkButton을 사용하고있었습니다. 병목이 남아있는 유일한 병이에요.
편집 :
지금은 내가 항상 컨트롤러에 널 (null)로 데이터를 얻고 이유를 알고하지 마십시오 자바 스크립트
$("a.anchor").click(function (e) {
e.preventDefault(); // This will stop default behavior
var validate = ValidateUsername();
if (validate) {
//alert(document.getElementById('usernameTextBox').value);
var str = document.getElementById('usernameTextBox').value;
$.ajax({
type: "POST",
url: "http://localhost/SSOMVC/Generic/ForgotPassword",
data: "data",
dataType: "text",
success: function (resultData) {
document.getElementById("usererror").textContent = resultData;
},
failure: function (error) {
}
});
}
});
@Html.ActionLink("Forgot Password", null, null, Model, new { @class = "anchor" })
public class GenericController : Controller
{
[HttpPost]
public ActionResult ForgotPassword(string data)
{
....
return Content(callResponse);
}
}
다음 사용하고 있습니다.
나는 actionlink를 사용하여 그렇게 할 수 있다고 생각지 않습니다. 가능한 경우 오버로드 중 하나 인 –
에서이 주제를 읽을 수 있습니다. https://stackoverflow.com/questions/2048778/asp-net-mvc-actionlink-and-post-method – arslanaybars
질문이 명확하지 않습니다. 'Model'은 ActionLink에서 직접 모델을 전달할 수 있습니다 – umasankar