[英]Redirect to a specific view in ASP.NET MVC 5
I'm sending by email info about my web admin, there is a link whit my controller/view, so when a user click that link the system should to go to login page (I have a page to do it).我正在通过电子邮件发送有关我的网络管理员的信息,我的控制器/视图有一个链接,因此当用户单击该链接时,系统应该转到登录页面(我有一个页面可以这样做)。
If the login is ok I want to go the specific controller / view / parameter.如果登录正常,我想转到特定的控制器/视图/参数。 By default the web admin goes to index page when the login is ok but I don't know how to define to go another view.
默认情况下,当登录正常时,网络管理员会转到索引页面,但我不知道如何定义转到另一个视图。
[AllowAnonymous] public JsonResult Login(string usuario, string contrasena) { [AllowAnonymous] public JsonResult Login(string usuario, string contrasena) {
Response respuesta = new Response();
LoginVM _usuarioResponse = new LoginVM();
try
{
mensaje = //login in database methid here
if (mensaje == "ok")
{
..
..
..
respuesta.status = Status.Success;
respuesta.message = mensaje;
respuesta.result = Url.Action("Index","Home");
}
else
{
respuesta.status = Status.Error;
respuesta.message = mensaje;
}
}
catch (Exception ex)
{
respuesta.status = Status.Error;
respuesta.message = ex.Message;
respuesta.result = ex.ToString();
}
return Json(respuesta, JsonRequestBehavior.AllowGet);
}
Im returning a url whit the main page after login, i want to go to another view after login when the user click on the email link我在登录后返回主页上的 url,当用户单击电子邮件链接时,我想在登录后转到另一个视图
You can do this using the RedirectToAction
method:您可以使用
RedirectToAction
方法执行此操作:
if (loginSuccessful)
{
return RedirectToAction("SpecificView", new { param1 = value1, param2 = value2 });
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.