-1
        [Route("/p/m")]
        [HttpPost]
        public IActionResult Add(Table t)
        {
            int id = int.Parse(HttpContext.Request.Query["Id"].ToString());
        }

and this my url

/p/m?Id=37

i try to get query string to my controller from url in asp.net core using this code but she give me this error

(Input string was not in a correct format.)
       61. int id = int.Parse(HttpContext.Request.Query["Id"].ToString());

1 Answers1

0

If you are not validating explicitly for numbers in the text field, in any case its better to use

int result=0;
if(int.TryParse(textBox1.Text,out result))

Now if the result is success then you can proceed with your calculations.

Input string was not in a correct format

MD. RAKIB HASAN
  • 3,670
  • 4
  • 22
  • 35