I am new to asp.net core application.
I have an asp.net core application which uses repository pattern. It have an api controller named ApplicationsAPIController.
ApplicationsAPIController has a GetApplications method which return all applications.
I have app published to remote server. While calling GetApplications api from postman throws 500 Internal Server Error with following HTML as response:
<h2 class="text-danger">An error occurred while processing your request. </h2>
<strong>Development</strong> environment will display more detailed information about the error that occurred.
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the
<strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to
<strong>Development</strong>, and restarting the application.
Note: Above api is working perfectly in development enviroment (locally).
As per the error, i think i have to set up a staging or production environment. But i could not find any good and step by step document to setup. I have tried it many ways but failed.
Can anyone please help me out.
The 500 error means your code encountered an issue, not that you forgot to assign correct environment. What you need to do is see what the actual error was. You have many options of which perhaps the fastest would be to enable dev-environment errors (consider temporarily adding
app.UseDeveloperExceptionPage(); or setting up the environment as "DEV"). A more robust approach would be to add some application error handling and logging (review Exception Filters topic).