1

So if I have this controller action:

[Route("{id:int}")]
public async Task<JsonResponse> GetAsync(int id)
{
}

Sending data to it from Angular, like this:

$http.get('/api/someController', { params: { id: someId } });

Doesn't cut it. It needs to have the URL generated to look like this:

/api/someController/someId

I would like to retain this Web API 2 feature, so how do I get Angular to build my URL differently?

Apart from the obvious:

$http.get('api/someController/' + someId);

If it has to be done the above way, I don't mind. However, I'm just wondering if someone has a solution for this? That isn't overly complicated.

1 Answer 1

1

I've implemented exactly what you are talking about by doing just what you mentioned:

$http.get('api/someController/' + someId);

I couldn't find a better way to do it and it seemed quite simple.

Sign up to request clarification or add additional context in comments.

2 Comments

Interesting, I might read down into the Angular Docs, see what I can come up with
I have typically used the restangular library (github.com/mgonto/restangular) to interact with WebAPI services and would definitely suggest it to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.