ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,539 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Below is my code of MVC JsonResult method
[HttpGet]
//[HttpGet("user/register/{OrgId:int}/{dealerId:int}")]
public JsonResult register(int? OrgId, int dealerId)
{
//my code
}
I am trying if query string value is not there means handle the error to not go yellow page above i have tried commented line but this is not working for me to validate url have query string values.
Use a nullable type for each input parameter and use a unique route.
[HttpGet("getbyOrgIdandDealerId")]
public IActionResult Get(int? OrgId, int? DealerId)
{
return Ok(new { orgId = OrgId, dealerId = DealerId });
}
URLs
https://localhost:44352/api/valuesgetbyOrgIdandDealerId?OrgId=1&DealerId=2
https://localhost:44352/api/values/getbyOrgIdandDealerId