从浏览器调用基于路由的 Web 服务 URL
Calling a Webservice based on Routing from browser URL
我创建了一个基本 Web 服务,它根据 DTO.Here 中定义的路由被调用是我的示例路由代码..
[Route("/students", Verbs = "GET")]
[Route("/students/{id}", Verbs = "GET")]
public class StudentRequestDto
{
public int Id { get; set; }
}
现在,当我通过 http://localhost:1661/Students
URL 直接调用此 Web 服务时,我能够得到响应,而当我尝试通过 http://localhost:1661/Students?id=1
调用它时,我得到 NullReferenceException
.
我通过 http://localhost:1661/Students?id=1
URL 第二次调用服务的方式是否正确,如果不是,正确的方式是什么..谢谢。
[Route("/students/{id}", Verbs = "GET")]
仅匹配:
http://localhost:1661/students/1
我创建了一个基本 Web 服务,它根据 DTO.Here 中定义的路由被调用是我的示例路由代码..
[Route("/students", Verbs = "GET")]
[Route("/students/{id}", Verbs = "GET")]
public class StudentRequestDto
{
public int Id { get; set; }
}
现在,当我通过 http://localhost:1661/Students
URL 直接调用此 Web 服务时,我能够得到响应,而当我尝试通过 http://localhost:1661/Students?id=1
调用它时,我得到 NullReferenceException
.
我通过 http://localhost:1661/Students?id=1
URL 第二次调用服务的方式是否正确,如果不是,正确的方式是什么..谢谢。
[Route("/students/{id}", Verbs = "GET")]
仅匹配:
http://localhost:1661/students/1