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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:14:33+00:00 2026-05-14T18:14:33+00:00

I setup a search route: routes.MapRoute( Search, Search/{q}, new { controller = Search, action

  • 0

I setup a search route:

routes.MapRoute(
 "Search",
 "Search/{q}",
 new { controller = "Search", action = "Index" }
);

The search form has an input box and a button. I want the search with a GET as below.

<% using(Html.BeginForm("Index", "Search", FormMethod.Get))
{%>
    <%:Html.TextBox("q")%>
        <span class="query-button">
        <input type="submit" value="select" /></span>
    <% } %>
 </div>

The action on the SearchController is:

public ActionResult Index(string q)
{
   // search logic here

   return View(new SearchResult(q));
}

The URL becomes like this:
http://localhost:19502/search?q=mvc+is+great

But I want the search to be like:
http://localhost:19502/search/mvc+is+great

How do I setup the route or the Html.BeginForm

  • 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-14T18:14:34+00:00Added an answer on May 14, 2026 at 6:14 pm

    There isn’t a straightforward way to do it with just a form. A form’s intended function is to transmit name/value pairs – using MVC doesn’t change that.

    So your options are:

    • Override the functionality of the form using Javascript by handling the submit event of the form, redirecting to the desired URL and returning false to prevent the form from actually submitting
    • Don’t use a form and handle the click event of a button to do the redirect.

    Your route is already correctly set up to handle this.

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

Sidebar

Related Questions

I have the following in my Global.asax.cs routes.MapRoute( Arrival, {partnerID}, new { controller =
I created a search and replace controller, with just an index action. Since it's
iam trying to setup an little search-engine for my website. I want to add
I'm trying to build a custom search form for an e-commerce setup built on
I want to setup search for my site. I couldn't find much information to
I just setup full-text search on my development database. I setup a new full-text
We are working with Fast Search for Sharepoint 2010 and had some backend setup
I am trying to set up an auto-complete search form with jQuery. I would
Here is my setup, a bit changed standard edition. # app/config/routing.yml _internal: resource: @AcmeDemoBundle/Controller/
I have set up my routes so I can search all posts with: /posts/search/foobar

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.