How to pass multiple parameters to a get method in ASP.NET Core

前端 未结 12 1403
说谎
说谎 2020-12-04 07:46

How can I pass in multiple parameters to Get methods in an MVC 6 controller. For example I want to be able to have something like the following.

[Route(\"api         


        
12条回答
  •  执笔经年
    2020-12-04 08:11

        public HttpResponseMessage Get(int id,string numb)
        {
    
            using (MarketEntities entities = new MarketEntities())
            {
              var ent=  entities.Api_For_Test.FirstOrDefault(e => e.ID == id && e.IDNO.ToString()== numb);
                if (ent != null)
                {
                    return Request.CreateResponse(HttpStatusCode.OK, ent);
                }
                else
                {
                    return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Applicant with ID " + id.ToString() + " not found in the system");
                }
            }
        }
    

提交回复
热议问题