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

  • Home
  • SEARCH
  • 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 132669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:17:57+00:00 2026-05-11T06:17:57+00:00

Simple enough, it would seem, but it turns out not to be – mainly

  • 0

Simple enough, it would seem, but it turns out not to be – mainly due to the fact that the View can’t possibly know which way through Model and Controller you got there. Regardless, it is a problem that needs a solution:

I have a login link, that takes the user to a form to enter username and password. When the user clicks ‘submit’, I want to redirect to the page he was viewing. The easiest way to do so seems to be specifying the url to the current page as a querystring (...?returnUrl=...) and everything else is already built.

But where do I find this url from my view, when rendering the link? I naturally can’t use a RedirectToActionResult as I don’t want to actually transfer the user – only render the url in a link. How to?


EDIT:

I have now started a bounty on this question, and therefore I see fit to clarify my needs as well.

I have a UserControl named Login.ascx in my Shared folder. In it, I render an ActionLink to the login form, and it is included in the footer on my Masterpage. What I want to accomplish is the following:

When the ActionLink is rendered, the querystring returnUrl is appended with the a route to the view that is currently being rendered. If this is accomplished, the user will be taken back to the page he/she was viewing after successful login with functionality that is already build into the ASP.NET MVC Framework.

The reason the previous answers have not been sufficient is mainly that they have not provided a way to build the route url to the current view. I do know how to append a querystring, but I do not know how to find out what to put in that string.

In order to mark an answer as the answer, I want a method to re-construct the route to the currently shown view, from a usercontrol in the masterpage.

  • 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. 2026-05-11T06:17:57+00:00Added an answer on May 11, 2026 at 6:17 am

    The solution is to use HttpContext.Current.Request.RawUrl like this:

    <%= Html.ActionLink('log on', 'LogIn', new { controller = 'User', returnUrl = HttpContext.Current.Request.RawUrl }) %> 

    Or with an extension method from MVC futures (Microsoft.Web.Mvc.dll):

    <%= Html.ActionLink<AccountController>(c => c.LogOn('name', 'password', false, HttpContext.Current.Request.RawUrl), 'login here')%> 

    ActionController is the default one in mvc but just add returnUrl to your own.

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

Sidebar

Ask A Question

Stats

  • Questions 85k
  • Answers 85k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For solve this problem, Please see the following step. Add… May 11, 2026 at 5:07 pm
  • Editorial Team
    Editorial Team added an answer It's possible to achieve this using Projections.SQLFunction. Working solution: ISQLFunction… May 11, 2026 at 5:07 pm
  • Editorial Team
    Editorial Team added an answer You are correct. If epsilon is involved, it will be… May 11, 2026 at 5:07 pm

Related Questions

Simple enough, it would seem, but it turns out not to be - mainly
I have read through the solutions to similar problems, but they all seem to
I hope this is a simple enough question for any SQL people out there...
With HTML/CSS, how can I make an element that has a width and/or height
The several uses to which the <title> tag is put complicates the question… As

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.