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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:43:34+00:00 2026-06-04T04:43:34+00:00

I have a View called Browse.chtml , where the user can enter a search

  • 0

I have a View called Browse.chtml, where the user can enter a search term, or leave the search term blank. When entering the search term, I want to direct the page to http://localhost:62019/Gallery/Browse/{Searchterm} and when nothing is entered, I want to direct the browser to http://localhost:62019/Gallery/Browse/Start/Here.

When I try this, I get the error:

The current request for action ‘Browse’ on controller type ‘GalleryController’ is ambiguous between the following action methods:
System.Web.Mvc.ActionResult Browse(System.String) on type AutoApp_MVC.Controllers.GalleryController
System.Web.Mvc.ActionResult Browse(Int32, System.String) on type AutoApp_MVC.Controllers.GalleryController

Everything I’m doing with MVC is for the first time. I’m not sure what else to try at this point.

public ActionResult Browse(string id)
{
    var summaries = /* search using id as search term */
    return View(summaries);
}

public ActionResult Browse(string name1, string name2)
{
    var summaries = /* default list when nothing entered */
    return View(summaries);
}

I also have this in Global.asax.cs:

    routes.MapRoute(
         "StartBrowse",
         "Gallery/Browse/{s1}/{s2}",
         new
         {
             controller = "Gallery",
             action = "Browse",
             s1 = UrlParameter.Optional,
             s2 = UrlParameter.Optional
         });



    routes.MapRoute(
         "ActualBrowse",
         "Gallery/Browse/{searchterm}",
         new
         {
             controller = "Gallery",
             action = "Browse",
             searchterm=UrlParameter.Optional
         });
  • 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-06-04T04:43:36+00:00Added an answer on June 4, 2026 at 4:43 am

    You can only have a maximum of 2 action methods with the same name on a controller, and in order to do that, 1 must be [HttpPost], and the other must be [HttpGet].

    Since both of your methods are GET, you should either rename one of the action methods or move it to a different controller.

    Though your 2 Browse methods are valid C# overloads, the MVC action method selector can’t figure out which method to invoke. It will try to match a route to the method (or vice versa), and this algoritm is not strongly-typed.

    You can accomplish what you want using custom routes pointing to different action methods:

    … in Global.asax

    routes.MapRoute( // this route must be declared first, before the one below it
         "StartBrowse",
         "Gallery/Browse/Start/Here",
         new
         {
             controller = "Gallery",
             action = "StartBrowse",
         });
    
    routes.MapRoute(
         "ActualBrowse",
         "Gallery/Browse/{searchterm}",
         new
         {
             controller = "Gallery",
             action = "Browse",
             searchterm = UrlParameter.Optional
         });
    

    … and in the controller…

    public ActionResult Browse(string id)
    {
        var summaries = /* search using id as search term */
        return View(summaries);
    }
    
    public ActionResult StartBrowse()
    {
        var summaries = /* default list when nothing entered */
        return View(summaries);
    }
    

    You might also be able to keep the action methods named the same in the controller, by applying an [ActionName] attribute to one to distinguish it. Using the same Global.asax as above, your controller would then look like this:

    public ActionResult Browse(string id)
    {
        var summaries = /* search using id as search term */
        return View(summaries);
    }
    
    [ActionName("StartBrowse")]
    public ActionResult Browse()
    {
        var summaries = /* default list when nothing entered */
        return View(summaries);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file called 34.php?session=2534464a39a2c97cb7113689726a4e52 in my /var/www/html folder but I can't view
I have a view (page) called DataGrowth.aspx, how can I display it in the
General context : MVVM application. I have a View called JobView. Its DataContext is
I have a Django view called change_priority. I'm posting a request to this view
I have a view and template called index.html. I have a image which is
I have a view who's methods are called by the accelerometer updates in the
I have a view with a class called drawingViewController, and I have the drawRect
I have a partial view that I have created called noteEditor. That is rendered
I have a primary link accommodation, then i have created a view , called
I have a segue (called ToSettingsSegue ) that pushes a custom view controller (

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.