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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:39:55+00:00 2026-06-14T16:39:55+00:00

I’m trying to make a RouteConfig in Web API, that allows following patterns: Patterns:

  • 0

I’m trying to make a RouteConfig in Web API, that allows following patterns:

Patterns:

/api/{controller}
/api/{controller}/{id} (int, optional)

/api/{controller}/{action}
/api/{controller}/{action}/{id} (int, optional)

Use cases:

/api/profile/ (get all profiles)
/api/profile/13 (get profile number 13)

/api/profile/sendemail/ (send email to all profiles)
/api/profile/sendmail/13 (send email to profile number 13)

What I’m trying is the following:

routes.MapHttpRoute(
    name: "ControllerAndID",
    routeTemplate: "api/{controller}/{id}",
    defaults: null,
    constraints: new { id = @"^\d+$" } // Dekkar heiltölur eingöngu í id parameter
);

routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "api/{controller}/{action}/{id}",
    defaults: new { action = "Get", id = RouteParameter.Optional }
);

The error I’m getting is:

Multiple actions were found that match the request:
\r\nMinarSidur.Models.DataTransfer.UserProfileDTO sendmail(System.String)
on type
MinarSidur.Controllers.ProfileController\r\nMinarSidur.Models.DataTransfer.UserProfileDTO
sendpaycheck(System.String) on type MinarSidur.Controllers.ProfileController

Can you help me accomplishing this?

  • 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-14T16:39:56+00:00Added an answer on June 14, 2026 at 4:39 pm

    Your exception was actually complaining about their being a conflict between these two methods on the Profile controller:

    • sendpaycheck(string)
    • sendmail(string)

    Not the Get and Get(?); although this would also be an issue.

    Really, when carrying out RPC actions that make changes or trigger actions you should use the POST verb. By doing this your routing issues mentioned above should be resolved.

    Updated

    Have you considered a more resource centric approach to your problem? In all cases here the resource is “Profile” and it appears to have a unique id of x. It appears to also have two other possible unique id’s email and ssn?

    If these were acceptable URL’s to you

    http://localhost/api/profile
    http://localhost/api/profile/x
    http://localhost/api/profile/?email=myemail@x.com
    http://localhost/api/profile/?ssn=x
    

    you could use:

    public class ProfileController : ApiController
    {
        public string Get(int id)
        {
            return string.Format("http://localhost/api/profile/{0}", id);
        }
    
        public string Get([FromUri] string email = null, [FromUri] int? ssn = null)
        {
            if (!string.IsNullOrEmpty(email))
            {
                return string.Format("http://localhost/api/profile/?email={0}", email);
            }
    
            if (ssn.HasValue)
            {
                return string.Format("http://localhost/api/profile/?ssn={0}", ssn.Value);
            }
    
            return "http://localhost/api/profile";
        }
    }
    

    With just the standard webapi routing:

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

    But

    If you did want to carry on with /email and /ssn you may have issues with the email… specifically with the “.” in the email address and this can confuse the routing engine… for this to work you must put a trailing slash i.e. http://localhost/api/profile/email/me@me.com/ I think you will find http://localhost/api/profile/email/me@me.com wont work.

    This supports:

    http://localhost/api/profile
    http://localhost/api/profile/x
    http://localhost/api/profile/email/myemail@x.com/
    http://localhost/api/profile/ssn/x
    

    I would try this and use (NB. the use of the name rpcId to differentiate the routes):

    public class ProfileController : ApiController
    {
        public string Get(int id)
        {
            return string.Format("http://localhost/api/profile/{0}", id);
        }
    
        public string Get()
        {
            return "http://localhost/api/profile";
        }
    
        [HttpGet]
        public string Ssn(int rpcId)
        {
            return string.Format("http://localhost/api/profile/ssn/{0}", rpcId);
    
        }
    
        [HttpGet]
        public string Email(string rpcId)
        {
            return string.Format("http://localhost/api/profile/email/{0}", rpcId);
    
        }
    }
    

    My routing would then be:

           config.Routes.MapHttpRoute(
             name: "ProfileRestApi",
             routeTemplate: "api/profile/{id}",
             defaults: new { id = RouteParameter.Optional, Controller = "Profile" }
             );
    
    
            config.Routes.MapHttpRoute(
                name: "PrfileRpcApi",
                routeTemplate: "api/profile/{action}/{rpcId}",
                defaults: new { Controller = "Profile" }
            );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.