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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:29:48+00:00 2026-05-31T01:29:48+00:00

In a ASP.NET MVC 4 app I have a view with a paged list

  • 0

In a ASP.NET MVC 4 app I have a view with a paged list (just a simple table, no telerik grid or anything like that). New values are fetched from the database when the user pages through the list.

On every row in that table there is an edit button, when clicking the button you are presented with an edit view and when you click save in that view you are redirected back to the view with the paged list.

The urls for the list view looks like this

http://localhost/Items/Page/1
http://localhost/Items/Page/2

The route looks like this

routes.MapRoute(
        name: "ItemsList",
        url :"Items/Page/{page}",
        defaults: new { controller = "Items", action = "Index", page = 1 },
            constraints: new {page = @"\d+"}
        );

My question is this: what is the preferred, most common way to store away the referring url, so when done editing an item, I can redirect the user back to the correct url

http://localhost/Items/Page/2

and not just to

http://localhost/Items

I’ve tried splitting up

Request.UrlReferrer.PathAndQuery

and storing those values around, and then build the url from those values but I have a feeling there is a much better solution to this problem. Any suggestions?

Update

Right now I’m thinking that I could put the UrlReferrer.PathAndQuery (if there are any values) as a property on the view model for the edit screen and then use that when deciding on where to redirect after a save.

Any thoughts out there on that approach?

  • 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-31T01:29:50+00:00Added an answer on May 31, 2026 at 1:29 am

    Here is my final solution to the problem, it’s not super elegant but it works.
    I added a property to the View model that could store the url. That value get’s stored in a hidden field.

    public class SkillEditModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string RedirectBackToUrl { get; set; }
    }
    

    In the controller Edit(GET) method I store the value with the view model

    if (!Request.UrlReferrer == null)
    {
        model.RedirectBackToUrl = Request.UrlReferrer.PathAndQuery;
    }
    

    And finally after saving the changes in Edit (POST) I did this

    if (!string.IsNullOrWhiteSpace(model.RedirectBackToUrl))
    {
        return new RedirectResult(model.RedirectBackToUrl);
    }
    
    return RedirectToAction("Index");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.Net-MVC app using LinqToSql. I have a subcontracts table, a service_lines
In my ASP.NET MVC app, I have a view that's calling Html.Action(MyAction, this.Model) -
In my ASP.net MVC App (using Razor views) I have a ProductDetails view. This
Using Unity in an ASP.Net MVC 2 app I have various dependencies on Controllers
Im trying to develop my first ASP.NET MVC web app and have run into
I have an ASP.NET MVC app and I want to add to each page
I have an asp.net mvc app, using JQuery UI dialog. I'm trying to submit
In my ASP.NET MVC app, I have a fairly complex edit page which combines
In my ASP.NET MVC app, I have an interface which acts as the template
I have implemented Membership Provider in my ASP.NET MVC app. Membership provider has the

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.