hello friends I go to the login.controller file from the login.js file, if the password is correct, I redirect to the home page.However, although it is redirected to the home page, the home page does not open, login.js falls into the error block and gives a json error.json.I do not parse.I only create Session.If the sessionID in the database is the same, I open the home page.thanks I have not found it for 2 days.
login.js file
function Login() {
var mail = $("#mail").val();
var password = $("#password").val();
if (mail == null || password == null) {
var dialog = bootbox.dialog({
title: "Uyarı",
message: "<label class='control-label'>invalid mail or password</label>",
size: 'small',
locale: 'tr',
onEscape: true,
buttons: {
ok: {
label: 'Tamam',
className: 'btn-default',
callback: function (result) {
runKey = false;
}
}
}, onEscape: function (result) {
runKey = false;
return false;
}
});
}
else {
user = {};
user["MAIL"] = mail;
user["PASSWORD"] = password;
$.ajax({
url: '/Login/Login',
type: 'POST',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
async: false,
data: JSON.stringify({
user: user
}),
success: function (result) {
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown)
}
}).done(function () {
});
}
homeController.cs
public ActionResult Index()
{
if (!string.IsNullOrEmpty(SessionManager.Get<string>("SystemAuthToken") as string))
{
string userID = string.Empty;
string serverSession = string.Empty;
string clientSession = string.Empty;
clientSession = BaseCore.Decrypt(Session["SystemAuthToken"].ToString(), true);
userID = SessionManager.Get<string>("USER_ID");
serverSession = new SettingBL().GetSession(int.Parse(userID));
SessionManager.Save<string>("USER_ID", userID);
if (serverSession.Equals(clientSession))
{
return View();
}
else
{
return RedirectToAction("Index", "Login");
}
}
else
{
bool cookie = new SettingController().CheckRememberMeCookie(this.HttpContext);
if (cookie)
return View();
else
return RedirectToAction("Index", "Login");
}
}
RouteConfig.cs
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Login", action = "Index", id = UrlParameter.Optional },
new string[] { "Project.Controllers" }
);
}
}
What I have tried:
login.js file json.parse error
error: function (jqXHR, textStatus, errorThrown) {
errorThrown > <pre>'<', "<!DOCTYPE "... is not valid JSON
}
if I do F5 after the error, it opens the home page