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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:45:59+00:00 2026-05-11T22:45:59+00:00

Yet another newbie with ASP.NET MVC! All I intend to do is for a

  • 0

Yet another newbie with ASP.NET MVC! All I intend to do is for a search textbox on my page, if I type something and click search, the url to be redirected to should have the following at the end, like in stackoverflow,

/search?q=searchedtext

So here is what I have now,

<input id="searchText" maxlength="100" type="text" name="query" />
    <a href="???"  class="searchButton">        
        Search        
    </a>

I have a function in my controller like this,

public ActionResult Search(string query)
 {

 }

Here is the route,

routes.MapRoute(
            "Search",                                            
            "Search",                          
            new { controller = "Posts", action = "Search"} 
        );

Can anyone fill in the gaps here :). Any comments appreciated.

  • 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-11T22:46:00+00:00Added an answer on May 11, 2026 at 10:46 pm

    Wrap it with form tag, set it’s method to “GET”, use input type=’submit’ for submitting form (instead of ‘a’ tag), name text input as query (already done), accept query as string in parameters (already done), call model from controller to process request, update ViewData.Model, return appropriate view result (partial, if AJAX is used).

    If you want to pass query through URL not through query string key/values,
    you must specify correct route for that.

    I guess that would be something like:

    routes.MapRoute(  
                "Search", // Route name  
                "search/{query}", // URL with parameters  
                new 
                  { controller = "search", action = "search"}  // Parameter defaults
            );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yet another Lucene.net question by an extreme newbie to it. This time, I have
I've just added yet another 3rd-party component to my .net project that contains a
Yet another IE is doing something different from other browsers question but this is
Yet another C#/.NET guy trying to learn Objective-C with big dreams of making millions
Yet another cross-domain iFrame question! I've search everywhere and believe this is impossible, so
Yet another TFrame IDE-registered-component question from me. Thanks for all the help, fellow programmers.
Yet another compile error for me: Error 1 'Model' conflicts with the declaration 'System.Web.Mvc.ViewUserControl.Model'
Yet another data structure doubt. I will get straight to it. This is what
Yet another PHP question. I've got two arrays: one string-based and the other numeric.
I was handling yet another KeyDown event in a user control when I wondered

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.