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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:43:39+00:00 2026-05-25T00:43:39+00:00

I need to implement a Search box on a C# MVC application that I’m

  • 0

I need to implement a “Search” box on a C# MVC application that I’m writting.

I’ve never had to implement a “Search” box before and I’ve been looking for some best practices and I’m not quite finding what I’m looking for.

I really like how the search works on stackoverflow.

If I type in a few random words, it navigates to the url http://stackoverflow/search?q=few+random+words.

If I type in title:random, it navigates to the url https://stackoverflow.com/search?q=title%3Arandom

What is happening both on the client (when I hit the enter key) and on the server to make the search happen?

I’ve purposely left out any thoughts I’ve already had on what is happening because I don’t want to bias the answers (or show my ignorance).

EDIT: I’m adding some specifics to this question.

  1. Where and how are the search terms transformed into the querystring parameters? ie few random words transformed into few+random+words,title:random transformed into title%3Arandom

  2. Where and how is few+random+words tranformed into variables used in a query?

  3. Is the query just one big Where clause that keeps appending “and” for each item that lands between the + signs?

I guess you could parse through the strings and do some replaces to achieve 1 and 2 but it sure looks like there is something already available that would automatically convert (and revert) the search strings. I’m trying to be prepared for my user’s typing ANYTHING in the search box.

  • 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-25T00:43:39+00:00Added an answer on May 25, 2026 at 12:43 am

    As much as I hate to do it, I have to answer my own question. What I couldn’t understand is how the search words where seemingly automatically transformed into querystring encoded parameters (ie all spaces where replaced with the + sign vs. being replace with %20). I didn’t understand how that was being achieved and I like it so I wanted the same abilities.

    In the end, what I should have done was copy the html from SO and tried it out on my own MVC site because it turns out that the encoding is built in/automatic. I didn’t have to do anything to get the functionality.

    Here is the basic HTML for the search box:

    <form id="frmsearch" action="~/Catalog/Search" method="get">
         <input id="q" name="q" value="@q" style="width:275px;"/>
         <input id="submit" name="submit" type="submit" style="font-weight:bold;" value="Search" />
    </form>
    

    Now, if you type “few random words” in the text box named “q” and click the submit button, the form action automatically takes you to “~/Catalog/Search?q=few+random+words” without any additional coding.

    Now for the best part, in the controller code, the “q” parameter is automatically available as “few random words” without any additional coding as well.

    Example:

    public ActionResult Search(string q)
    {
        //q = "few random words" (no need to remove '+' signs) 
        var model = GetSearchResults(q)
    
        return View(model);
    } 
    

    The only thing I haven’t tested out it how it would handle scripting attacks but I think I’m going to get that for free as well. : )

    Hope this helps anyone who stumbles across this answer. Thank you to everyone who submitted answers trying to help. I’m sorry if my question wasn’t clear enough.

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

Sidebar

Related Questions

I have below combo box in mvvm-wpf application. I need to implement Text search
I need to implement some search functionality within a Rails application. Most of the
I need to implement some kind of metric space search in Postgres(*) (PL or
I am looking to implement a search text box as follows: When user starts
I am looking for some inspiration to implement a search engine for my winforms
I have a application already working fine. I need to implement a quick search
I need to implement some plot like that or that in my app ,
I need to implement some search functionalities in my app and want to use
I need to implement a data structure that supports insertion deletion and search in
I need to implement a Query Object Pattern in Java for my customizable search

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.