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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:39:15+00:00 2026-06-12T08:39:15+00:00

I have a c# web api (.net 4) web application. I have several controllers.

  • 0

I have a c# web api (.net 4) web application. I have several controllers. I’d like to map a new controller to the root directory for the web app.

So, I have http://localhost/listproducts

I’d like the url to be http://localhost

But I don’t know how to tell the controller to use the root directory. It seems to be configured based on the name.

The solution I went with is:

config.Routes.MapHttpRoute(
      name: "ListProductsApi",
             routeTemplate: "",
             defaults: new { controller = "ListProducts" } // Parameter defaults
);

The trick is the defaults: new { controller = "ListProducts" } line. (I need a POST action so I just left action out. Apparently when you want the root route “/” you need to explicitly name the controller.

  • 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-12T08:39:17+00:00Added an answer on June 12, 2026 at 8:39 am

    You simply need to change the default route you already have. It should currently look something like this:

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index",
                        id = UrlParameter.Optional }
    );
    

    Change controller = "Home" to controller = "listproducts".

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

Sidebar

Related Questions

I have an ASP.NET MVC 4 application which uses the new ASP.NET Web API.
Using the ASP.NET Web-Api, I have the following POST setup in my controller. When
I have a ASP.NET MVC 4 application with Web API. It's working great. But
I have an ASP.NET Web API application, with an ApiController that features asynchronous methods,
I am new to ASP.Net MVC and ASP.Net web api. I have worked on
I am developing a ASP.Net Web API application and I have used AuthorizeAttribute for
We currently have a classic ASP.NET web application which serves as our API. It
I have an asp.net web api application which is acting as a Relay to
I have a layered web application that I built with ASP.NET MVC 4, WebAPI
I have an ASP.NET Web API (version 4) REST service where I need to

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.