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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:12:37+00:00 2026-05-12T09:12:37+00:00

I have a search page which allows users to further filter thier results based

  • 0

I have a search page which allows users to further filter thier results based on criteria within a certain set.

You start a search by searching for all items within a “tag”. The URL created for this would look like

search/index?tag=TagA

On the page there are a list of tags that are also in this result set.

What I want is so in this list of tags the URL’s generated are

<a href="search/index?tag=TagA,TagB">TagB</a>

It’s not good enough just to append onto the URL as there will be other parameters added such as page numbers and other search criteria (I have not included them for brevity)

I’m aware I could probably hack this on the server side but nothing feels very elegant and I was wondering if there was a neat solution for this.

This is all done in ASP MVC and as such I have a nice simple partial view to list these tags:

<%if(Model.Count()>0){ %>    
    <ul>
    <%foreach(Tag t in Model){ %>
        <li><%=t.name%></li>
    <%} %>
    </ul> 
<%} %

Any ideas?

  • 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-12T09:12:38+00:00Added an answer on May 12, 2026 at 9:12 am

    This ain’t good looking code, but it might give you an idea:

      public static string CurrentUrl
            (this UrlHelper helper)
        {
            return GenerateUrl
                (helper, GetParameters(helper), null, null);
        }
    
        public static string CurrentUrlWith
            (this UrlHelper helper, string key, string value)
        {
            return GenerateUrl
                (helper, GetParameters(helper), key, value);
        }
    
    
    
     private static Dictionary<string, object> GetParameters
                (UrlHelper helper)
            {
                var context = helper.RequestContext.HttpContext;
                var request = context.Request;
                var parameters = new Dictionary<string, object>();
                request.Form.CopyTo(parameters);
                request.QueryString.CopyTo(parameters);
    
                return parameters;
            }
    
            //TODO: refactor
            private static string GenerateUrl
                (UrlHelper helper, Dictionary<string, object> parameters,
                 string key, string value)
            {
                var context = helper.RequestContext.HttpContext;
                var request = context.Request;
                string query = "?",
                       url = request.FilePath;
    
                foreach (var parameter in parameters)
                    if (parameter.Key != key)
                        query += string.Format("&{0}={1}",
                            helper.Encode(parameter.Key), 
                            helper.Encode(parameter.Value.ToString()));
    
                if (key != null && value != null)
                    query += string.Format("&{0}={1}", helper.Encode(key), helper.Encode(value));
    
                if (query.Length > 1)
                    query = query.Remove(1, 1);
    
                return url + query;
            }
    

    Usage looks like this:

    <a href="<%= Url.CurrentUrlWith("page", (Model.TotalPages).ToString())%>" 
        class="p-last">Last page</a>
    

    If you want to involve javascript, you might want to check out this jQuery plugin.

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

Sidebar

Related Questions

I have a search page which uses a simple ajax request to get new
I have the following scenario. I have a search page which is split into
I have a search page in which I am searching data by passing multiple
I have xpath page.search(//table[@class='campaign']//table) which returns two tables. I need to choose only first
I have an html page called search.html which contains sliders, they work perfectly in
I have a search page that if there is results in the list it
I have a page with a search bar, facets, and a list of results.
I have a website which allows users to submit photos of wildlife. Once uploaded,
I have a master page that contains a search box which is validated as
I have two forms on one page: a results form and a search form.

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.