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

  • Home
  • SEARCH
  • 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 8761315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:15:23+00:00 2026-06-13T15:15:23+00:00

I have a WebApi project and I am trying to add an area to

  • 0

I have a WebApi project and I am trying to add an area to it.

Is there something different that needs to be done when adding a new area to a webapi project vs a mvc4 application?

I have a simple area registration like

 public class MobileAreaRegistration : AreaRegistration
{
    public override string AreaName
    {
        get
        {
            return "Mobile";
        }
    }

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Mobile_default",
            "Mobile/{controller}/{action}/{id}",
            new { action = "Index", id = UrlParameter.Optional }

        );
    }
}

A controller like

  public class BusinessDetailsController : BaseController
{
    public string Index()
    {
        return "hello world";
    }
    public HttpResponseMessage Get()
    {
        var data = new List<string> {"Store 1", "Store 2", "Store 3"};
        return Request.CreateResponse(HttpStatusCode.OK, data);
    }
}

However I can never reach the api. Am I doing something stupid or is there an extra step with the webapi that needs to be done?

  • 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-13T15:15:24+00:00Added an answer on June 13, 2026 at 3:15 pm

    Your code registers an MVC route for the Area, not a Web API route.

    To do that use the MapHttpRoute extension method (you’ll need to add a using statement for System.Web.Http).

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.Routes.MapHttpRoute(
                name: "AdminApi",
                routeTemplate: "admin/api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
    
            context.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
    

    However, Areas are not really supported OOTB in ASP.NET Web API and you’ll get an exception if you have two controllers with the same name (regardless of whether they are in different areas).

    To support this scenario you need to change the way that controllers are selected. You’ll find an article that covers how to do this here.

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

Sidebar

Related Questions

I have trying to learn MVC4 Web API. I am running my project from
I'm trying to add a link to a basic MvcScaffolding project that outputs all
I have a webapi project mvc4 rc and a mvc4 rc web application deployed
I have a maven3 webapp (war) project that has 2 dependencies. One is a
I have been busy in my project creating a webapp (in struts) that manages
I have a desktop webapi server that I want to expose to clients through
I have a Asp.net WebAPI service that is hosted on AppHarbor which throws 404
I have a layered web application that I built with ASP.NET MVC 4, WebAPI
I am migrating a project that was developed using WebApi Preview 5 (when it
I am fairly new to Servlet Filters and have basically joined a project using

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.