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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:29:49+00:00 2026-06-18T08:29:49+00:00

I have a MVC4 web project with WebAPI enabled. I want to post data

  • 0

I have a MVC4 web project with WebAPI enabled.

I want to post data to the API controller but the post is not working, I am getting a 404 every time (breakpoint inside the Add method is not hit)….

Here is the code:

public class IncidentSessionLogController : ApiController
{
   [HttpPost]
   public void Add(MyInputDTO inputData)
   {
   }
}

I use action based routing:

public static void Register(HttpConfiguration config)
{
   config.Routes.MapHttpRoute(
       name: "ControllerAndAction",
       routeTemplate: "api/{controller}/{action}");

   config.Routes.MapHttpRoute(
       name: "ControllerAndActionAndId",
       routeTemplate: "api/{controller}/{action}/{id}",
       defaults: new { id = RouteParameter.Optional });
}

I use Fiddler to post the data:

http://localhost:42901/api/IncidentSessionLog/Add

My site is hosted in IIS express for development currently, I add the JSON object literal in the request body in Fiddler.

  • 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-18T08:29:50+00:00Added an answer on June 18, 2026 at 8:29 am

    Fixed it, thanks to my collegue !

    The MVC routing(which I forgot to post originally), was interfering with the API routing, so I have to add a constraint to the MVC routing :

    routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Game", action = "Start", id = UrlParameter.Optional },
                    constraints: new { controller = @"^((?!(api)).)*$" });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am starting to use MVC4 Web API project, I have controller with multiple
I have trying to learn MVC4 Web API. I am running my project from
I am currently working on MVC4 SinglePage Application. I have a Web Api method
I have been catching up with MVC4 Web API and WCF Data Service. From
I have a webapi project mvc4 rc and a mvc4 rc web application deployed
Let say I have two methods in MVC 4 Web API controller: public IQueryable<A>
I have a basic MVC4 web project in VSTS 2012 to play around with
I have the following solution: Web api project. MVC 4 project. I need to
I am working on an MVC4 razor project. I have a list of role
I have a Web API project as part of my solution (also containing an

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.