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 254921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:53:15+00:00 2026-05-11T21:53:15+00:00

I have a login page. In my web.config I setup a loginUrl so that

  • 0

I have a login page. In my web.config I setup a loginUrl so that if a user tries to go to an “Authorized” page and are not authorized they will get redirected to the login page.

Now I noticed when this happens and the user gets redirected from a “Authorized” page the url from the page they are getting redirected from gets appended to the login url.

So that way when they do login I can use that I can send them back to the page they where trying to get too.

So this is how the Url would look:

http://localhost:2505/CMS_Account/LogOn?ReturnUrl=%2fCMS_Home%2fIndex

So I am trying to capture the ReturnUrl querystring part as a parameter in my View.

But I can’t get it took work.

So I found out if I change my Form for the login to this:

<% using (Html.BeginForm()) ........

Then I can capture the ReturnURl for some reason no problem.

However how I have it right now I have this:

<% using (Html.BeginForm("Login","Authentication",FormMethod.Post,new { id = "frm_Login"})) .....

Once I try to pass the parameters into the BeginForm it stops capturing the ReturnUrl.

I don’t know why it stops. Some people say that it is because I am using the default route and somehow if you don’t put anything in the beingForm it magically can figure out the ReturnUrl with the default url.

Soon as you put something in BeginForm it seems to get dumb and you need to give it a route to tell it what to do.

I don’t know how to write this route though. I tried quite a few different combinations and they all failed and everyone who tells me right a route never tell me how it should look like.

So I don’t know what to try anymore.

What I tried

routes.MapRoute(
   "CMS_Account",  // Route name
   "CMS_Account/{action}/{ReturnUrl}",  // URL with parameters
   new { controller = "CMS_Account", action = "LogOn",}  // Parameter defaults
);

routes.MapRoute(
   "CMS_Account",  // Route name
   "CMS_Account/{action}/{ReturnUrl}",   // URL with parameters
   new { controller = "CMS_Account", action = "LogOn", ReturnUrl = ""}  // Parameter defaults
);

routes.MapRoute(
   "CMS_Account",   // Route name
   "{controller}/{action}/{ReturnUrl}",  // URL with parameters
   new { controller = "CMS_Account", action = "LogOn", ReturnUrl = ""}  // Parameter defaults
);

routes.MapRoute(
   "CMS_Account",   // Route name
   "{controller}/{action}/{id}",  // URL with parameters
   new { controller = "CMS_Account", action = "LogOn", id = ""}  // Parameter defaults
);

routes.MapRoute(
   "CMS_Account",  // Route name
   "{controller}/{action}/", // URL with parameters
   new { controller = "CMS_Account", action = "LogOn"}  // Parameter defaults
);
  • 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-11T21:53:15+00:00Added an answer on May 11, 2026 at 9:53 pm

    You don’t need to change your routes. The cool thing with the routing engine is that if you add an additional route value that isn’t declared in the route itself, the routing engine will throw it on the end as a get variable.

    E.g. Have you tried putting the ReturnUrl into BeginFrom?

    Controller as Dennis suggested:

    public ActionResult LogOn(string ReturnURL) {
        ViewData["ReturnURL"] = ReturnURL;
        return View();
    }
    

    Then in your view you’ll need to use the BeginForm(string action, string controller, object routeValues, FormMethod method, object htmlAttributes) overload. E.g.

    Html.BeginForm("Login",
                   "Authentication",
                   new { @returnUrl = ViewData["ReturnUrl"] },
                   FormMethod.Post,
                   new { @id = "frm_Login" })
    

    HTHs,
    Charles

    EDIT: Just on a side note, the other way around it would be to put the ReturnUrl into a hidden input field – after initial getting it from the querystring. This means the value is then in your post collection and you don’t have to worry about getting it back into your querystring.

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

Sidebar

Related Questions

I have made a web application that uses master page for Login & Logout
I have a Login page that captures User input like this. MD5calc ss =
I have a login page that works only with Firefox. It does not work
If have the following web.config : <configuration> <system.web> <authentication mode=Forms> <forms name=MembershipCookie loginUrl=Login.aspx protection=All
In ASP.NET web app, I have login.aspx. I force that every user access through
In my web.config I have this authentication setting: <authentication mode=Forms> <forms loginUrl=login.aspx name=signin path=/
I have this on my web.config file: <authentication mode=Forms> <forms loginUrl=login.aspx defaultUrl=Venues.aspx /> </authentication>
I have a login page. When the user enters valid Username and Password another
Scenario: I have a login page which uses ajax to validate a user and
I'm using ASP.NET MVC 2 and have a login page that is secured via

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.