第一篇文章。
您好 我有一个下拉窗口,您可以从控制器登录/索引验证您的电子邮件和密码以进行登录,这些参数与我编写的一些Jquery代码相吻合。
但是当登录成功时,它会在下拉窗口中打开一个页面,不刷新主页面。我该怎么办?
以下是代码;
function GirisYap() {
$("#btnGiris").prop("disabled", true);
$('#Loading').show();
$.ajax({
url: "/Login/Index",
type: "POST",
data: $("#frmGiris").serialize(),
success: function (result) {
if (result == "OK") {
$('#mesajAlani').hide();
$("#btnGiris").prop("disabled", true);
$('#Loading').show();
$('#loading-message').html("");
$('#loading-message').html("Yönlendiriliyor...");
window.location = "/";
}
else {
$('#mesajAlani').show();
$("#mesaj").html(result);
$("#btnGiris").prop("disabled", false);
$('#Loading').hide();
$('#loading-message').html = "Kontrol ediliyor...";
}
}
});
}
这些是获取视图中参数的Form;
<form class="frm-single" id="frmGiris">
<div class="inside">
<div class="frm-input">
<input type="text" placeholder="E-mail" class="form-control submit_on_enter" name="Email">
<i class="fa fa-user frm-ico"></i>
</div>
<div class="frm-input">
<input type="password" placeholder="Parola" class="form-control submit_on_enter" name="Parola">
<i class="fa fa-lock frm-ico"></i>
</div>
<button id="btnGiris" type="button" class="frm-submit" onclick="GirisYap(); return false;">Giriş<i class="fa fa-arrow-circle-right"></i></button>
<div class="checkbox" id="mesajAlani" style="display:none">
<div id="mesaj" class="alert alert-info" style="background-color:red;color:white;">Giriş için gerekli bilgileri doldur.</div>
</div>
<div id="Loading" style="text-align:center;display:none;">
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
<p id="loading-message">Kontrol ediliyor...</p>
</div>
</div>
</form>
答案 0 :(得分:1)
我认为这是缓存问题。将以下代码添加到您的操作以禁用输出缓存。
public class MyController : Controller
{
[OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)] // will disable caching for Index only
public ActionResult Index()
{
return View();
}
}