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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:57:52+00:00 2026-05-28T03:57:52+00:00

hope someone can help because I’ve been racking my brains for the best part

  • 0

hope someone can help because I’ve been racking my brains for the best part of yesterday evening! Basically, I’m trying to get a search form working using HttpGet so I can potentially retrieve results from an external source via the URL like:

http://url.com/Area/Controller/Action/SearchCategory/SearchCriteria

I create and pass a model to my view containing two properties for SearchCategory and SearchCriteria and have the associated HTML controls in the view. This works perfectly if I choose both a category AND enter something for my criteria. However, if I don’t enter anything in my criteria I get an infinite redirect. My route for this particular feature looks like this:

context.MapRoute(
    "Dashboard-Search",
    "Area/Controller/Action/{SearchCategory}/{SearchCriteria}",
    new { 
        controller = "Controller", 
        action = "Action", 
        SearchCategory = "", 
        SearchCriteria = "" 
    }
);

I do have my model implementing IValidateableObject and validate that something has been entered, but obviously the route binding is done before anything can be validated.

Any ideas???

Routes

context.MapRoute(
    "Dashboard-Search-NoCriteria",
    "HEP/Dashboard/Search/{category}",
    new { controller = "Dashboard", action = "Search", category = "Case No" }
);

context.MapRoute(
    "Dashboard-Search",
    "HEP/Dashboard/Search/{category}/{criteria}",
    new { controller = "Dashboard", action = "Search", category = "Case No", criteria = "" }
);

Controller Action

[HttpGet]
public ActionResult Search(string SearchCategory, string SearchCriteria)
{
    // create new instance of model and add search criteria so entered
    // data persists on post back
    DashboardModel model = new DashboardModel() {
        SearchCategory = SearchCategory,
        SearchCriteria = SearchCriteria
    };
    model.Search(SearchCategory, SearchCriteria);

    // return the HTML view of another controller that displays the same list,
    // only this time, the list is filtered according to GET data
    return View("Overview", model);
}

HTML Form

@using (Html.BeginForm("Search", "Dashboard", FormMethod.Get)) {

    @Html.LabelFor(m => m.SearchCategory, "Category:")
    @Html.DropDownListFor(m => m.SearchCategory, new List<SelectListItem>() {
        new SelectListItem() { Selected = true, Text = "Category", Value = "Category" }
    })

    @Html.LabelFor(m => m.SearchCriteria, "Criteria:")
    @Html.TextBoxFor(m => m.SearchCriteria)

    <input type="submit" value="Search" class="button" />

}
  • 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-28T03:57:52+00:00Added an answer on May 28, 2026 at 3:57 am

    Your routes right now do not correspond to your search form.

    URL that satisfies your Dashboard-Search route should look like

    http://example.com/HEP/Dashboard/Search/SampleCategory/SampleCriteria
    

    Your form in turn will produce a GET request to URL like this:

    http://example.com/HEP/Dashboard/Search/?Category=SampleCategory&Criteria=SampleCriteria
    

    Most probably your method Search(string SearchCategory, string SearchCriteria) is not ever called – I’d suggest that your request is redirected back to the method which is just showing your search view without actually performing any search.

    Please show the entire RegisterRoutes method if you need more explanations or code.

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

Sidebar

Related Questions

I hope someone can help, I am trying to enable enable ASP.Net Impersonation under
I hope someone can help with the following. I'm trying to create a user-specific
I hope someone can help me as I've already spent several hours trying to
I really hope someone can help on this because I'm learning cocoa and have
I hope someone can help me with the following scenario because I'm breaking my
Hope someone can help me and not sure if this should be here or
hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID
Hope someone can help i cant seem to get my head around this, i
Hope someone can help me out with this problem I am having. I just
I hope someone can help me with this, as I'm unable to find the

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.