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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:23:09+00:00 2026-05-15T03:23:09+00:00

i have defined a route as below: context.MapRoute(SearchEngineWebSearch, search/web/{query}/{index}/{size}, new { controller = search,

  • 0

i have defined a route as below:

context.MapRoute("SearchEngineWebSearch", "search/web/{query}/{index}/{size}",
                            new
                            {
                                controller = "search",
                                action = "web",
                                query = "",
                                index = 0,
                                size = 5
                            });

and action method to handle request match with that:

public System.Web.Mvc.ActionResult Web(string query = "", int index = 0, int size = 5)
    {
        if (string.IsNullOrEmpty(query))
            return RedirectToRoute("SearchEngineBasicSearch");
        var search = new Search();
        var results = search.PerformSearch(query, index, size);
        ViewData["Query"] = query;
        if (results != null && results.Count() > 0)
        {
            ViewData["Results"]= results;
            return View("Web");
        }
        else return View("Not-Found");
    }

and form to sent parameter to action method:

<% using (Html.BeginForm("Web", "Search", FormMethod.Post))
       { %>
    <input name="query" type="text" value="<%: ViewData["Query"]%>" class="search-field" />
    <input type="submit" value="Search" class="search-button" />
    <input type="hidden" name="index" value="2" />
    <input type="hidden" name="size" value="2" />
    <%} %>

now after click on submit and sending value to action method all route values updated but url values still is equals to first time of sending parameter. for example if i sent for first time request such as http://localhost/search/web/google and for next time http://localhost/search/web/yahoo, query parameter which passed to action method is yahoo but url after postback is http://localhost/search/web/google still!

can anybody help me plz? 😉

  • 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-15T03:23:10+00:00Added an answer on May 15, 2026 at 3:23 am

    Try something like

    return RedirectToAction("Web", 
       new { query = query, index = index, size = size}); 
    

    instead of return View("Web");.

    Also, note that you should perform a GET instead of a POST. And the index and size parameters may be ommitted if they were submitted with the default values.

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

Sidebar

Related Questions

Suppose I have defined route like that, context.MapRoute( Preview, /preview/{id}/{type}, new { controller =
I have the following route defined routes.MapRoute( ItemName, {controller}/{action}/{projectName}/{name}, new { controller = Home,
i defined two routes in global.asax like below context.MapRoute(HomeRedirect, , new { controller =
I have the following route defined: routes.MapRoute(name: StateResults, url: {state}/{searchTerm}, defaults: new { controller
In ASP.NET MVC, I have a defined catch-all route as below: routes.MapRoute( TagsRoute, tags/{*tags},
i have defined a route culture/Controller/action/id... my controller contains following action.. [OutputCache(Duration=60*10)] public ActionResult
I want clean URLs and have defined two routes: routes.MapRoute( Search, Search, new {
I have the following route defined in my Global.asax (MVC 3 web project): routes.MapRoute(
heres my setup: http://www.example.com/<module>/<controller>/<action> I have this route defined: $router->addRoute( 'editUser', new Zend_Controller_Router_Route('admin/users/edit/:id', array(
In my MVC application I have a default route defined: routes.MapRoute( Default, // Route

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.