As per the postman or web to check API as in the local environment it works. But as I update my launchSettings.json with "ASPNETCORE_ENVIRONMENT": "Production" from "Development" in two places as per the image location path below.
And added in configuration setting new application setting of Azure Application Settings as per research over the websites.
Here are some websites which i referred to for solutions.
- https://github.com/MicrosoftDocs/azure-docs/issues/29976
- How and where to define an environment variable on Azure
- ASP.NET Core deployment to IIS error: Development environment should not be enabled in deployed applications
Still, it shows me error on postman when I check Web API after hitting the URL.
<div class="container">
<main role="main" class="pb-3">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
<p>
<strong>Request ID:</strong>
<code>|14a7ad86-47801a7069301d42.</code>
</p>
<h3>Development Mode</h3>
<p>
Swapping to
<strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the
<strong>Development</strong> environment by setting the
<strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to
<strong>Development</strong>
and restarting the app.
</p>
</main>
</div>
Update 1:-
This Url for Web Api is working.
https://kerisuiteapp.azurewebsites.net/Staff/StaffTest
Here is my code which i used.
[AllowAnonymous]
[HttpGet("StaffTest")]
public IActionResult StaffTest()
{
var test = new { name = "joy", number = "123123123", Fax = "234234"
};
return Json(test);
}
But this shows me error.
https://kerisuiteapp.azurewebsites.net/Staff/GetStaff
Here is the code which is not working on Azure.
[AllowAnonymous]
[HttpGet("GetStaff")]
public IActionResult Staff()
{
try
{
var staffModel = _StaffService.GetStaff();
return Ok(staffModel);
}
catch (Exception ex)
{
return Json(ex);
}
}
public List<Staff> GetStaff(){
return uow.Repository<Staff>().Get();
}