C# asp.net core 3.1中的查询字符串(输入字符串的格式不正确。)

C# asp.net core 3.1中的查询字符串(输入字符串的格式不正确。),c#,asp.net-core,C#,Asp.net Core,这是我的网址 [Route("/p/m")] [HttpPost] public IActionResult Add(Table t) { int id = int.Parse(HttpContext.Request.Query["Id"].ToString()); } 我尝试使用此代码从asp.net内核中的url获取控制器的查询字符串,但她给了我此

这是我的网址

        [Route("/p/m")]
        [HttpPost]
        public IActionResult Add(Table t)
        {
            int id = int.Parse(HttpContext.Request.Query["Id"].ToString());
        }
我尝试使用此代码从asp.net内核中的url获取控制器的查询字符串,但她给了我此错误

/p/m?Id=37

如果您没有在文本字段中明确验证数字,那么无论如何,最好使用

(Input string was not in a correct format.)
       61. int id = int.Parse(HttpContext.Request.Query["Id"].ToString());
现在,如果结果是成功的,那么您可以继续计算


该错误具有很强的描述性,查询字符串对于Id为空,或者它包含一些非int类型的额外字符。查询字符串不为空。是否有值您可以从实体类中获取值?控制器IActionResults应该已经具有c#实体类中的值。返回0,但我的查询字符串值不是0
int result=0;
if(int.TryParse(textBox1.Text,out result))