Click here to Skip to main content
15,919,121 members
Please Sign up or sign in to vote.
4.20/5 (2 votes)
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:

C#
@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 ?
Posted
Updated 9-Mar-14 22:45pm
v4
Comments
Sampath Lokuge 9-Mar-14 8:21am    
Your issue is may be routing problem ? check that ? What's the value of "ViewBag.ReturnUrl" ?
Kornfeld Eliyahu Peter 9-Mar-14 9:06am    
It's not here - I think it should be in the controller code...
Jahangir Khan 9-Mar-14 13:16pm    
Yes Sir found it and fixed it , Thanks for assistence
VICK 10-Mar-14 4:44am    
It would be nice to post a solution describing "How you solved it" for helping others.

1 solution

You can do it in Cotroller's Action Method

C#
public class LoginController : Controller
   {
       public ActionResult Login()
       {
           //Your code of login
           //if(//success)
               return RedirectToAction("Member"); //If Member Action Method exist
           //else
               return View();
       }
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900