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

  • Home
  • SEARCH
  • 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 9040709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:03:39+00:00 2026-06-16T10:03:39+00:00

I am trying to create a REST service using the .NET Web API. The

  • 0

I am trying to create a REST service using the .NET Web API. The URL I am trying to map is

/api/<controller>/<videoId>/chapters

I have a route setup that looks like the following:

RouteTable.Routes.MapHttpRoute(name: "Route1",
  routeTemplate: "api/video/{id}/{action}",
  defaults: new { controller = "Video", action = "Chapters"});

Which maps the following function in the controller:

[HttpGet]
[ActionName("Chapters")]
public string GetChapters() {
  return "get chapters";
}

Everything maps correctly, but how do I get access to the <video_id> parameter in the URL from within the GetChapters function?

As a concrete example, the URL looks like this:

http://localhost/api/video/1/chapters

How do I get access to the parameters after controller, in this 1?

  • 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-16T10:03:41+00:00Added an answer on June 16, 2026 at 10:03 am

    Just add id parameter to your web service method – it will be automatically blinded by ASP.NET Web API to the query string parameter or {id} parameter defined in the route:

    public string GetChapters(int id) {
        return "get chapters by video id";
    }
    

    Also you can omit [HttpGet] and [ActionName] attributes, because in Web API action methods with name starting from ‘Get’ will be mapped to GET requests (‘Post’ to POST and so on), and other part of the method name (‘Chapters’) is treated as the action name.

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

Sidebar

Related Questions

I'm trying to create a REST service in zend framework. I'm using zend server.
I got this problem while trying to access REST web service using GWT client.
I am currently trying to create a REST web service for my django site
I'm trying to create a REST web service that exposes the following Django model:
I created a new wcf rest service using .net 4. I have created a
I am trying to create a API based service using Symfony2 which is the
I am trying to create a logging service using WCF Rest. It looks something
I'm using WCF REST service with API key template and trying to enforce validation
So trying to create a rest service but I keep getting an error: If
I've got a simple REST based service for which I am trying to create

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.