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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:02:22+00:00 2026-06-17T12:02:22+00:00

I may have just been staring at this too long, or maybe I just

  • 0

I may have just been staring at this too long, or maybe I just misunderstand the idea behind WebAPI, but I’m looking to see if there is a way to make it so the routing table responds to CUSTOMIZED action names. For example, I want:

// -> /api/student/studentRecord?studentId=1
[HttpGet]
public Student StudentRecord(int studentId){
    //Do Something and return the Student Record
}

// -> /api/student/newStudent?name=john
[HttpPost]
public int NewStudent(String name){
    //Do whatever and return the new id
}

I’m not sure what I’m missing here, or if it can even be done. I’ve been scouring the internets for a while, and can’t seem to figure it out.

Is the point of webAPI to just have a single PUT, POST, GET, etc in each controller, or can I do what I want it to do?

I’ve played around with the routing, but I think I made it worse! Every time I try to call something now, I get the same method being called.

This is what I have in the route config file:

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
  • 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-17T12:02:23+00:00Added an answer on June 17, 2026 at 12:02 pm

    You don’t even need the ‘magical’ action selector linked above (although it does sound quite cool) – WebApi allows to include the action name (= controller method name, unless overriden) in the url.

    So, in your example:

    // -> /api/student/studentRecord?studentId=1
    [HttpGet]
    public Student StudentRecord(int studentId){}
    

    the routing template would look like this:

    routeTemplate: "api/{controller}/{action}"
    
    • controller will be resolved to student
    • action to studentrecord
    • I don’t think you need to put the query string param in the template at all (unless you want to be able to append it to the url part)

    Have a read through this to get more details:
    http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-in-aspnet-web-api

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

Sidebar

Related Questions

This question may have been asked before, but I had trouble finding an answer,
This question may have been asked already - but unfortunately, I could not find
This may be too obscure of an question, but I've been troubleshooting a baffling
I have been staring and googling this but I cannot see what I have
This may have been answered before, and if so, point me to the answer.
Ok, I've been racking my brain on this one solo for too long. I've
This may have been asked somewhere else - unfortunately it's quite a difficult thing
This may be a bit of a nooby question, I have been trying to
I think I may have encountered a bug in mysql, or is it just
this may seem like a stupid question, but it is stumping me nontheless. I'm

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.