重定向的链接在哪里 [英] Where is the Link for redirection
问题描述
好的亲爱的朋友们,这是另一个难题,即登录表单,当用户登录时,用户可以在网站/应用程序的主页上找到他/她自己。例如,当使用用户名和密码按下登录按钮时,然后 - > http:// localhost:50706 /显示我想要的是显示http:// localhost:50706 /会员/页面现在我查看了这段代码,但我似乎无法找到我应该更改超链接的地方,这里是登录的代码:
Ok dear firends, here is another conundrum there is login form and when user is logged in, user finds him/her self on the main page of the website / application. Example is then when use pushes the login button with user name and password then --> http://localhost:50706/ show up what I want it is to show http://localhost:50706/Member/ page now I looked in this code but I cant seem to find the place where I should change the hyperlink, here is the code for login:
@model TrailApp.Models.LoginModel
@{
ViewBag.Title = "Log in";
}
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
</hgroup>
<section id="loginForm">
<h2>Use a local account to log in.</h2>
@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Log in Form</legend>
<ol>
<li>
@Html.LabelFor(m => m.UserName)
@Html.TextBoxFor(m => m.UserName)
@Html.ValidationMessageFor(m => m.UserName)
</li>
<li>
@Html.LabelFor(m => m.Password)
@Html.PasswordFor(m => m.Password)
@Html.ValidationMessageFor(m => m.Password)
</li>
<li>
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe, new { @class = "checkbox" })
</li>
</ol>
<input type="submit" value="Log in" />
</fieldset>
<p>
@Html.ActionLink("Register", "Register") if you don't have an account.
</p>
}
</section>
<section class="social" id="socialLoginForm">
<h2>Use another service to log in.</h2>
@Html.Action("ExternalLoginsList", new { ReturnUrl = ViewBag.ReturnUrl })
</section>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
这是正确的地方还是我在其他地方?
is this the right place or I am some where else ?
推荐答案
你可以在Cotroller的行动方法中做到这一点/>
You can do it in Cotroller's Action Method
public class LoginController : Controller
{
public ActionResult Login()
{
//Your code of login
//if(//success)
return RedirectToAction("Member"); //If Member Action Method exist
//else
return View();
}
}
这篇关于重定向的链接在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!