Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 951173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:41:26+00:00 2026-05-15T23:41:26+00:00

I’m creating asp.net mvc login page. This is simple. Same as others. Controller contains

  • 0

I’m creating asp.net mvc login page. This is simple. Same as others. Controller contains 2 method.

My problem is

I’m debugging First LogOn method. ReturnUrl has value. for example "Admin/Index". After debuggin Second LogOn method. But ReturnUrl is Null.

public ActionResult LogOn(string ReturnUrl) // First method
{
    return View();
}

[HttpPost]        
public ActionResult LogOn(string eUserName, string ePassword, Boolean rememberMe, string ReturnUrl) //Second Method
{
 ...
}

My View is here>>

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Login</title>    
</head>
<body>
<table style="width: 100%">
            <tr>
                <td align="center">
                    <div style="width: 800px;">
                        <%=Html.ValidationSummary() %>
                    </div>
                </td>
            </tr>
            <tr>
               <td align="center">
                 <% Html.RenderPartial("LoginControl"); %>
               </td>
            </tr>
    </table>
</body>
</html>

Logincontrol

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<div style="text-align: left; width:150px;margin-top:20px;">
    <% using (Html.BeginForm("Logon", "Account", FormMethod.Post))
       { %>

    <div>
        Хэрэглэгчийн нэр:</div>
    <div>
        <%= Html.TextBox("eUserName") %>
    </div>
    <div style="margin-top:5px;">
        Нууц үг:</div>
    <div >
        <%= Html.Password("ePassword") %>
    </div>
    <div style="margin-top:5px;">
        <%= Html.CheckBox("rememberMe") %>
        <label class="inline" for="rememberMe">
            Намайг сана?</label>
    </div>
    <div style="text-align:center;margin-top:5px;">
        <input type="submit" value="Нэвтрэх" />
    </div>


    <%} %>
</div>

Why ReturnUrl returns null?

What happening?

EDIT

Thanks Tim Roberts

Last correct code is here>>

<% using (Html.BeginForm("Logon", "Account",new { ReturnUrl = HttpContext.Current.Request.QueryString["returnUrl"]} FormMethod.Post)){ %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:41:27+00:00Added an answer on May 15, 2026 at 11:41 pm

    Since you’re implementing your own login mechanism, you’ll need to ensure that the returnUrl parameter is passed along when the user clicks on your submit button. One way of doing this is to use an overload of the BeginForm method:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    <div style="text-align: left; width:150px;margin-top:20px;">
       <% using (Html.BeginForm("Logon", "Account", new { ReturnUrl = HttpContext.Current.Request.RawUrl }, FormMethod.Post))
          { %>
          ... as before
       <% } %>
    </div>
    

    Which should pass the URL along in the query string and then bind it to the action method’s ReturnUrl parameter. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.