Lara
Lara

Reputation: 3021

Calling a Webservice based on Routing from browser URL

I have created a Basic Webservice which gets invoked as per the Routing defined in the DTO.Here is my sample Routing Code..

[Route("/students", Verbs = "GET")] 
[Route("/students/{id}", Verbs = "GET")]
public class StudentRequestDto
{
    public int Id { get; set; }
}

Now when i am calling this webservice directly by http://localhost:1661/Students URL i am able to get the response whereas when i am trying to call it by http://localhost:1661/Students?id=1then i am getting NullReferenceException .

Is my way of calling the Service second time by http://localhost:1661/Students?id=1 URL correct , if not what is the correct way..Thanks.

Upvotes: 1

Views: 26

Answers (1)

Mariusz
Mariusz

Reputation: 442

[Route("/students/{id}", Verbs = "GET")]

only matches:

http://localhost:1661/students/1

Upvotes: 1

Related Questions