Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development Mode Error #7581

Closed
donalatorre opened this issue Jul 12, 2018 — with docs.microsoft.com · 16 comments
Closed

Development Mode Error #7581

donalatorre opened this issue Jul 12, 2018 — with docs.microsoft.com · 16 comments
Labels
Pri2 Priority 2 Source - Docs.ms Docs Customer feedback via GitHub Issue
Milestone

Comments

Copy link

I followed this tutorial. It worked fine in the local host. When I deployed it in my azure website, I obviously changed the reply url to the public link. So I was able to select an account, enter password, and allow the permissions, but then I got this error:

An error occurred while processing your request.
Request ID: 0HLF7H4694HLM:00000006
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.

I changed the environment mode to Production in my App, same error. I'm starting to suspect it has to do with something else. Any help?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@Rick-Anderson
Copy link
Contributor

See https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-apps/troubleshoot?view=aspnetcore-2.1

And try setting the ASPNETCORE_ENVIRONMENT environment variable to Development,

@Rick-Anderson Rick-Anderson added Source - Docs.ms Docs Customer feedback via GitHub Issue P4 labels Jul 12, 2018
@Rick-Anderson Rick-Anderson added this to the Backlog milestone Jul 12, 2018
Copy link
Author

Thank you for your quick response, Rick. This link did not have the answer, however, I was able to solve it. Turns out, when you deploy your web app, you must go to the appsettings.json file, and replace the "DefaultConnection" from "ConnectionStrings" with a server key generated in azure or some other database service. Indeed the log is misleading, since when the app is deployed, it is in Production mode, but the debugger notes a local default connection string, so it gets confused and assumes it is in Development mode instead.

This tutorial is very complete, but I strongly recommend the writers to include this key piece of information, since it is essential for deploying the app.

@Rick-Anderson Rick-Anderson added Pri2 Priority 2 and removed P4 labels Jul 13, 2018
@Rick-Anderson
Copy link
Contributor

Copy link

Hello,
When I paste the following code in the Startup, I get an error on ApplicationUser. It says the type or namespace ApplicationUser could not be found or you are missing an assembly reference. I was wondering if know why?
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores()
.AddDefaultTokenProviders();

@KathyWebTest
Copy link

Hi, I think your solution "...appsettings.json file, and replace the "DefaultConnection" from "ConnectionStrings" with a server key generated in azure..." could really help me. Would you be able to give me some more information about where you found the server key generated in Azure please - and also the syntax you used in the JSON file? Would really appreciate your help. Cheers

@Rick-Anderson
Copy link
Contributor

you must go to the appsettings.json file, and replace the "DefaultConnection" from "ConnectionStrings" with a server key generated in azure or some other database service

That's the wrong approach. See https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.2#providers

@joseffaghihi
Copy link

joseffaghihi commented Jan 9, 2019 via email

@priyankagargc27
Copy link

Hi Dona, I having the same issue. I put the right serve connection string in my appsetting.json file but still getting the same error. can you please help me out with this.

@koo9
Copy link

koo9 commented May 3, 2019

deploy to IIS not azure, getting the same error, anything else?

@koo9
Copy link

koo9 commented May 4, 2019

had the same issue, turned out to be the this call
//.AddValidationKeyFromFile(Configuration.GetSection("SigninKeyCredentials"), _loggerFactory.CreateLogger())

that caused the trouble. use the developersigningcredentials seems to work fine.

@abdullah-alimam
Copy link

abdullah-alimam commented May 15, 2019

I think this will help
all you need is to display the real error by adding these lines in startup:

app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();

without the condition of if (env.IsDevelopment())

and remove these lines if exists

app.UseExceptionHandler("/Error");
app.UseHsts();

then just let the app displaying the error like in development mode so you can search about it and fix it

after you fix the error(s) you can remove these changes so users can not see the error :)

@jais232
Copy link

jais232 commented Apr 5, 2020

This tutorial is very complete, but I strongly recommend the writers to include this key piece of information, since it is essential for deploying the app.

Can you please help me how to find the server key generated in Azure? urgent need

@Rick-Anderson
Copy link
Contributor

This has nothing to do with Azure deployment. That's a different article.

@FahimNuman
Copy link

i face same problem in 3.1 . any one help me?

@oshinanika
Copy link

I think this will help
all you need is to display the real error by adding these lines in startup:

app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();

without the condition of if (env.IsDevelopment())

and remove these lines if exists

app.UseExceptionHandler("/Error");
app.UseHsts();

then just let the app displaying the error like in development mode so you can search about it and fix it

after you fix the error(s) you can remove these changes so users can not see the error :)

@abdullah-alimam, Your solution helped me a lot.

Here's how my I solved my problem:

I had the same problem (ASP.NET CORE 3.1) but changing "ASPNETCORE_ENVIRONMENT" did not helped.

Seeing @abdullah-alimam 's answer, I found that in Startup.cs, Configure method, this code was hiding the real issue.

 if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

Then I deleted the If block and added Database error pages ( You might need to Install Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore from NuGet )

app.UseDatabserrorPages();

So your Startup.cs will look like this

app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
            
app.UseHttpsRedirection();

//Others will be Okay

Then you will see the real errors on the webpage. For me it was

Login failed for user IIS APPPOOL\DefaultAppPool

So I had to run a GRANT SCRIPT. I just had to run this script on my SQL Server

IF NOT EXISTS (SELECT name FROM sys.server_principals WHERE name = 'IIS APPPOOL\DefaultAppPool')
BEGIN
    CREATE LOGIN [IIS APPPOOL\DefaultAppPool] 
      FROM WINDOWS WITH DEFAULT_DATABASE=[master], 
      DEFAULT_LANGUAGE=[us_english]
END
GO
CREATE USER [WebDatabaseUser] 
  FOR LOGIN [IIS APPPOOL\DefaultAppPool]
GO
EXEC sp_addrolemember 'db_owner', 'WebDatabaseUser'
GO

You can see this link : https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-to-iis

And my problem was solved. Hope this helps somebody.

@DanBer39
Copy link

DanBer39 commented Aug 8, 2022

@abdullah-alimam's solution worked for me. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pri2 Priority 2 Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests