Techy
Techy

Reputation: 2132

Error after deploying asp.net core app to azure

After deploying my asp.net core app to azure for the first time and ran it, I got the following error:

Error. An error occurred while processing your request. Development Mode Swapping to Development environment will display more detailed information about the error that occurred.

Development environment should not be enabled in deployed applications, 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 ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.

Please note that I tried debug and release mode when publishing in visual studio and I made sure that I chose the default migration and have the connection string as well. If possible, can you tell me how to enable development mode as shown or explain the error further? Thank you

Edit: As per the suggestion I received I found the following in cloud explorer log:

Msvsmon was unable to start a server named '127.0.0.1:50867'. The following error occurred: An instance of the remote debugger is already running on this computer, or another process is already bound to the specified TCP/IP port.

Upvotes: 18

Views: 27341

Answers (4)

heman123
heman123

Reputation: 3003

Visually describing where you need to perform this action. I read it many times but took me time to figure out my way. enter image description here

  1. Go to configuration
  2. New Application setting
  3. Name : ASPNETCORE_ENVIRONMENT Value: Development

Upvotes: 0

Fco Javier Balón
Fco Javier Balón

Reputation: 455

It is a security measure used in production mode so that any user does not got sensitive exception information from our app.

You can change ASPNETCORE_ENVIRONMENT from "Production" to "Development".

Another option is to change the code for the Configure () method in Startup.cs. It is this method makes a validation:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Error");
    }

    ...
}

It is not recommended, but you can eliminate this condition:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseDeveloperExceptionPage();
    ...
}

Upvotes: 4

Techy
Techy

Reputation: 2132

thanks for your comments. I was able to find error details by adding the following key in application settings in azure portal: ASPNETCORE_ENVIRONMENT with value: Development

I have created a new question regarding the error itself: InvalidOperationException: Could not find 'UserSecretsIdAttribute' on assembly

Thank you

Upvotes: 5

Just so it's clear - still something that comes up in ASP.NET Core 2.0 - and as @Techy stated - is in Azure. Go to Azure, click on your Web App –> "Applications Settings" –> go down to the “App Settings” section and add the “ASPNETCORE_ENVIRONMENT” and “Development”

Azure Portal

Upvotes: 31

Related Questions