Всем доброго времени суток. Вопрос возможно примитивный, но я только начал разбираться с ASP .NET Core. В общем вопрос следующий: как после выполнения определенного кода в методе OnGetMain() открыть /вызвать другую html страницу? Кратко опишу метод OnGetMain, с помощью с html с помощью ajax в данный метод отправляются данные пользователя, в методе происходит их проверка и если все ОК, то запись заносится в БД и выводится сооббещение об успешной регистрации. И вот далее, мне необходимо открыть другую html страницу в моем проекте, страница называется main.cshtml. Ниже приведу полный код метода и JS функции, которая его вызывает. Спасибо. Код | public IActionResult OnGetMain(string login, string passw, string phone) { this.login_ = login; this.passw_ = passw; this.phone_ = phone;
if (String.IsNullOrEmpty(login_)) { return new JsonResult(new { text = "You have not filled login!" }); }
if (login_.Length > 50) { return new JsonResult(new { text = "Login can't be more then 50 symbols!" }); }
CheckEmail ch_login = new CheckEmail(login_); if (!ch_login.CheckEM()) { return new JsonResult(new { text = "Incorrect format of login! It should have an email format." }); }
if (String.IsNullOrEmpty(passw_)) { return new JsonResult(new { text = "You have not filled password!" }); }
if (login_ == passw_) { return new JsonResult(new { text = "Login and Password can't be the same!" }); }
if (passw_.Length > 50) { return new JsonResult(new { text = "Password can't be more then 50 symbols!" }); }
if (!CheckPassw.CheckPassword(passw_)) { return new JsonResult(new { text = "Password doesn't meet the requirements. It have to have 8 or more symbols, contain one or more number, uppercase letter, lowercase letter and symbols like (@#\\$%!)." }); }
ConnectDB cd = new ConnectDB(); if (cd.CheckUserExsist(login_)) { return new JsonResult(new { text = $"Login <b>{login_}</b> has already registered!" }); }
//Make SHA512 for password ComputeSHA512 sha = new ComputeSHA512(); string sha_passw = sha.GetSHA512(passw_);
//Generating random code for activating users's login Random rnd = new Random(); int rand_numb = rnd.Next(1000, 1000000);
///////Send code with Email. Do it in thread for asynchronous executing Thread th = new Thread(obj => { SendRegCode snd = new SendRegCode(rand_numb, login_); snd.SendCode(); }); th.IsBackground = true; th.Start();
///////Insert user in table ConnectDB con = new ConnectDB(); con.AddUser(login_, sha_passw, rand_numb);
return new JsonResult(new { text = "User registered!", log = login_ });
}
|
Функция JS: Код | <script> function reg() { $.ajax({ type: 'GET', traditional: true, dataType: 'json', contentType: 'application/json', url: '/Index/?handler=Main', data: { 'login': $('#NEW_USER_LOGIN_EMAIL').textbox('getValue'), 'passw': $('#NEW_PASSW').passwordbox('getValue'), 'phone': $('#NEW_PHONE_NUMB').numberbox('getValue') }, success: function (res) { if (res.text != "User registered!") { $.messager.alert('Information', res.text, 'info'); } else { $('#dlg_window_login_reg').dialog('close'); $('#USR_REG').text(res.log); $('#USR_LOG').val(res.log); $('#input_code').dialog('open').dialog('center').dialog('setTitle', 'Input code'); } }, error: function () { $.messager.alert('Warning', 'Did not work', 'warning'); } }); } </script>
|
|