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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:02:57+00:00 2026-06-08T13:02:57+00:00

I have a project (named Product.Api ) that has some controllers used for our

  • 0

I have a project (named Product.Api) that has some controllers used for our WebAPI site. The controllers are in a namespace Product.Api.Controllers. The project also has some other helper stuff as well. This is compiled into a library.

I also have another regular ASP.NET MVC4 website named Product.Web. This has Controllers (under the namespace Product.Web.Controllers), Models and Views (in its corresponding folders). It also has a Global.asax.cs which has the routing information.

When the site is created in IIS (.NET 4.5, IIS7, integrated mode, etc), I copy the Product.Api dll into the bin folder. The Product.Web is the main site.

Now I want the url http://www.product.com/api/{Controller}/{id} to map to the WebAPI stuff and http://www.product.com/{Controller}/{Action}/{id} to map to the regular MVC.

This is what I have right now as my routes:

routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}", 
                defaults: new {id = RouteParameter.Optional}
            ).Constraints["Namespaces"] = new string[] { "Product.Api.Controllers" };

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

Unfortunately when I go to an api url (in this case the example was http://www.product.com/api/Tables/ (or even when I define an id), I get a HTTP 404 error.

http://www.product.com/Home/Index works fine.

Oddly enough I tried the routing debugger tool and I still had issues. In fact I could never see the output of the debugger. http://www.product.com/Home/Index and http://www.product.com/ both show the view but everything api/* still shows 404. I have yet to see any output from the debugger.

So is there anyway to get the desired effect?

Edit: I noticed that my global.asax.cs file was in the Product.Web namespace. I changed it to be in the Product namespace and still no go.

  • 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-08T13:02:59+00:00Added an answer on June 8, 2026 at 1:02 pm
    routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}", 
                    defaults: new {id = RouteParameter.Optional}
                ).Constraints["Namespaces"] = new string[] { "Product.Api.Controllers" };
    

    this will not work with MapHttpRoute.

    If you want to use ApiController routes from the other bin, just remove the constraints, the runtime will automatically pick up your ApiControllers from the bin. MapHttpRoute will not interfere with your MVC controllers and vice versa, so the constraints are not needed anyway.

    Alternatively use this to contraint your HttpRoute namespace

    routes.DataTokens["Namespaces"] = new string[] {"MyNamespace"};
    

    Or use this solution (but that’s really only needed if you keep stuff outside of bin.)

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

Sidebar

Related Questions

I have a project that references a number of open source libraries, some new,
I'm working on a solution that has a Core project with a DbContext (named
I have a class named Product in class library project. I am using SubSonic
I am making a project that sells product and I want to have a
Which is your preference? Let's say we have a generic Product table that has
I have an xcode project that has 4 targets (2 apps, 1 iPhone and
I have an application that was in a folder named project, I moved all
I have some model classes like Customer , Product , etc. in my project
I have a project and two files in the project are named as query-structures.h
I have the following in a project named testApp: (testAppViewController is the valid name

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.