此方法:
public IActionResult Index(string CatId)
可能退货
NotFound("Cat does not exist");
或
this.Content(catname);
但是,如果找到了猫,这就是实际返回的信息:
Microsoft.AspNetCore.Mvc.ContentResult
如何获取我真正想要的字符串?
答案 0 :(得分:-2)
public IActionResult Index(string CatId)
{
string catName=null;
try
{
/*your code to get catname*/
if (catName != null)
{
return Ok(catName);
}
return NotFound();
}
catch (Exception e)
{
return InternalServerError(e);
}
}