c# - Response Redirect Doesn't Work -
i have problem in mvc response redirect. in code seems right, code goes it, right thing page doesn't refresh. function triggered button , function has response redirect code.
here code. goes home/index, can see while i'm debugging home view doesn't show.
note : first page login view
public class logincontroller : controller { // get: login [intranetaction] public actionresult user() { return view(); } public void checkauthentication(userlogininfo logininfo) { bool isauthenticated = new ldapservicemanager().isauthenticated(logininfo); if (isauthenticated) { response.redirect("/home/index"); response.end(); } else { response.redirect("/", false); } }
homecontroller index
public actionresult index() { if (isdbexists()) { _contactlist = new list<contact>(); updateoperations(); return view(_contactlist); } response.redirect("/loading/loadingscreen"); return null; }
button cshtml
$("#loginbutton") .click(function() { if ($("#usernamebox").val() == '') { $("#usernamefield").addclass('has-error'); $('#usernamespan').css("display", "block"); } else { $("#usernamefield").removeclass('has-error'); } if ($("#passwordbox").val() == '') { $("#passwordfield").addclass('has-error'); $('#passwordspan').css("display", "block"); } else { $("#passwordfield").removeclass('has-error'); } if ($("#usernamebox").val() != "" && $("#passwordbox").val() != "") { $.post("/login/checkauthentication", { username: $("#usernamebox").val(), password: $("#passwordbox").val() }); } });
the yellow line can go index nothing changes on display
you should use redirecttoaction
:
public actionresult index() { if (isdbexists()) { _contactlist = new list<contact>(); updateoperations(); return view(_contactlist); } return redirecttoaction("actionname", "controllername"); }
returning null
wrong :)
Comments
Post a Comment