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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:13:46+00:00 2026-06-16T20:13:46+00:00

I am learning ASP.NET MVC4 Web APIs. I would like to create a new

  • 0

I am learning ASP.NET MVC4 Web APIs.
I would like to create a new method that would be which receives two parameters

[HttpPost] 
public string MarkAsSeen(int objectID, long userID)

I would like to consume it using jquery:

$.ajax({
        type: "POST",
        url: "/api/tutorial/MarkAsSeen",
        data: JSON.stringify({ objectID: _obj, profileID: _pid }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (result) {
            alert(_tutorial + ' seen');
        },async: true
});

I have my route configured this way

config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}"
            );

But it just doesn’t work:

No HTTP resource was found that matches the request URI ‘http://local.dev.unation.com/api/tutorial/MarkAsSeen’.”,”MessageDetail”:”No action was found on the controller ‘Tutorial’ that matches the request.

IF I change the route’s template to api/{controller}/{action}/{objectID}/{profileID} and the jquery method to add this info on the url: /api/tutorial/MarkAsSeen/ + _obj + / + _pid
it works.

I would not like to perform these changes because:

  • I would like to have one general route to all actions (so their parameter names/quantity shouldn’t matter)
  • This url appending is just ugly, I would like to use the data attribute

Can you tell me what I am doing wrong?

tks!

  • 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-16T20:13:47+00:00Added an answer on June 16, 2026 at 8:13 pm

    Web.Api doesn’t really like multiple parameters. The easiest solution is to create a new type which holds your data:

    public class MarkAsSeenRequest
    {
        public int objectID { get; set; }
    
        public int profileID { get; set; }
    }
    

    And use that in your controller action:

    [HttpPost] 
    public string MarkAsSeen(MarkAsSeenRequest request)
    {
        //...
    }
    

    It should work fine with your original route:

    config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}"
            );
    

    For further reading:

    • How WebAPI does Parameter Binding
    • WebAPI Parameter binding under the hood
    • Sending HTML Form Data
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning ASP.Net. I have a dynamically created ImageButton that I would like
I am still learning ASP.NET MVC. With webforms, I would create a new folder
I am learning ASP.NET and would like to know what are the must have
I'm learning ASP.NET MVC4, this in my first experience in Web development. I'm dealing
I am new to asp.net MVC, using MVC4 at the moment, learning by tutorials
I'm currently learning ASP.Net MVC; I'm using Visual Studio Express 2012 with MVC4 (which
I'm learning ASP.NET MVC Framework, From some articles like this , it seems that
I'm currently learning ASP.NET MVC and using Nhibernate. I would like to use Cascading
I just started learning ASP.NET MVC4 today. After reading tutorials, downloading VS 2012, and
I am learning ASP.NET MVC now a days and I have found that most

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.