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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:22:22+00:00 2026-05-12T00:22:22+00:00

Title said it all. Some context: I got a search mechanism – search view,

  • 0

Title said it all.

Some context:
I got a search mechanism – search view, search results view and a details view (which represents one item of results, like a formview in webforms). I want a link in details view, which would return user to search results view.

Ideas:
Just read about TempData, but i guess that wouldn’t help, cause user might call some actions before he wants to return.

Session might work, but I’m not sure how exactly i should handle it.

I don’t want to use javascript to accomplish this.

Edit:
Seems that i’ll stick with eu-ge-ne`s solution. Here’s result:

#region usages

using System.Web.Mvc;
using CompanyName.UI.UIApp.Infrastructure.Enums;

#endregion

namespace CompanyName.UI.UIApp.Infrastructure.Filters
{
    /// <summary>
    /// Apply on action method to store URL of request in session
    /// </summary>
    public class RememberUrlAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting  
           (ActionExecutingContext filterContext)
        {
            var httpContext = filterContext.HttpContext;

            if (httpContext.Request.RequestType == "GET"
                && !httpContext.Request.IsAjaxRequest())
            {
                SessionManager
                .Save(SessionKey.PreviousUrl,
                      SessionManager.Get(SessionKey.CurrentUrl) ??
                      httpContext.Request.Url);

                SessionManager
                .Save(SessionKey.CurrentUrl,
                      httpContext.Request.Url);
            }
        }
    }
}

Btw, how does .IsAjaxRequest() method works? It understands only MS AJAX or it’s smarter than that?

  • 1 1 Answer
  • 1 View
  • 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-12T00:22:23+00:00Added an answer on May 12, 2026 at 12:22 am

    I think you need something like this custom filter (not tested – have no VS at the moment):

    public class PrevUrlAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var httpContext = filterContext.HttpContext;
            var session = filterContext.HttpContext.Session;
    
            if (httpContext.Request.RequestType == "GET"
                && !httpContext.Request.IsAjaxRequest())
            {
                session["PrevUrl"] = session["CurUrl"] ?? httpContext.Request.Url;
                session["CurUrl"] = httpContext.Request.Url;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As the title said, I got a problem! i encountered the RJS Error:[object error],the
We've got some in-house applications built in MFC, with OpenGL drawing routines. They all
Title said it all. im just wandering if there something i can use in
Like I said in the topic title, there's some translations missing on PROD (but
all is said in the title, I want to get from an element all
maybe some one can help me with this... I have a custom search button
As the title said: I would like to find all elements that are on
As the title said: Is it possible to send an email (using php mail())
    As the title said, I want to match ip address with batch in windows,
I have a notification which should give me some parameters when opening an activity

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.