I really getting stuck in this routing thing
I created a new route like this here. And this is working, but when i try create a new one within the same controller, it not working. I am a web 2 api beginner.
[Route("api/itemstoredetails/{Item_Number}")]
[HttpGet]
public IHttpActionResult Getitemstoredetail2(string Item_number)
{
itemstoredetail itemstoredetail = db.itemstoredetails.Find(Item_number);
if (itemstoredetail == null)
{
return NotFound();
}
return Ok(itemstoredetail);
}
when i then call the api with this:
https://localhost:44338/api/itemstoredetails/Getitemstoredetail2?Item_number=55555
i get this
<itemstoredetail xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/NormalappApi">
<Goods_In_order>666</Goods_In_order>
<Item_Number>55555</Item_Number>
<Min_stock_P>66</Min_stock_P>
<Min_stock_s>666</Min_stock_s>
<Store_code>111</Store_code>
<current_stock>96</current_stock>
<store i:nil="true"/>
</itemstoredetail>
But if i then create a new route like this under, where i ask for store code instead, i get an error that says "This localhost page can’t be found" what is wrong
[Route("api/itemstoredetails/{Store_code}")]
[HttpGet]
public IHttpActionResult klaus(string Store_code)
{
itemstoredetail itemstoredetail = db.itemstoredetails.Find(Store_code);
if (itemstoredetail == null)
{
return NotFound();
}
return Ok(itemstoredetail);
}
Aucun commentaire:
Enregistrer un commentaire