I have a .Net Core 2.+ app, it publishes to my shared hosting fine thru web publish, and it worked (registering a user, data entering the SQl database) fine the first few times after i was able to publish it to remote server. Now when trying to register
a new user, when hitting "Register" button, it renders the "
An error occurred while processing your request.
Development Mode
Swapping to theDevelopmentenvironment displays detailed information about the error that occurred....
error. According to possible fix on https://www.tutorialsteacher.com/core/aspnet-core-environment-variable , I have gone into VS , right clicked on the project name, > Debug,
and changed the ASPNETCORE_ENVIRONMENT to Production (I also did likewise on the launchsettings.json ), still the same error.
??
Ned
I have gone into VS , right clicked on the project name, > Debug, and changed the ASPNETCORE_ENVIRONMENT to Production (I also did likewise on the launchsettings.json ), still the same error.
Could you share the stack trace?It seems you could also do not run the project successfully on local kestrel.Your project may contain mistakes.Please check your code.
Best Regards,
Rena
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
The error is saying if you enable developer mode, a more detailed error page will display (if you keep that code), not that setting the mode will fix the error.
The problem is, the error occurs when I run it LIVE (after web publish) on the remote server. I do not get this error when running on localhost. So this is where the confusion lies
It appears you did not write proper error logging, so you could understand errors generated in production. Ione issue is that you can only get full stack trace from a debug build. Just deploy a debug build, and if you don’t know how to set dev mode, just
take the if statement out and force the developer debug page.
The concept is very simple. Run the application in development mode so you can see the error.
You can force developer mode in the startup.cs file as recommended above. This requires a deployment but that should not be an issue. since the application is not working
//if (env.IsDevelopment())
//{
// app.UseDeveloperExceptionPage();
//}
//else
//{
// app.UseExceptionHandler("/Home/Error");
// // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
// app.UseHsts();
//}
app.UseDeveloperExceptionPage();
Member
29 Points
162 Posts
ASPNETCORE_ENVIRONMENT Development- Production problems
May 16, 2020 12:02 AM|Norkle|LINK
I have a .Net Core 2.+ app, it publishes to my shared hosting fine thru web publish, and it worked (registering a user, data entering the SQl database) fine the first few times after i was able to publish it to remote server. Now when trying to register a new user, when hitting "Register" button, it renders the "
An error occurred while processing your request.
Development Mode
Swapping to the Development environment displays detailed information about the error that occurred....
error. According to possible fix on https://www.tutorialsteacher.com/core/aspnet-core-environment-variable , I have gone into VS , right clicked on the project name, > Debug, and changed the ASPNETCORE_ENVIRONMENT to Production (I also did likewise on the launchsettings.json ), still the same error.
??
Ned
Contributor
2690 Points
874 Posts
Re: ASPNETCORE_ENVIRONMENT Development- Production problems
May 16, 2020 06:42 AM|Rena Ni|LINK
Hi Norkle,
Could you share the stack trace?It seems you could also do not run the project successfully on local kestrel.Your project may contain mistakes.Please check your code.
Best Regards,
Rena
All-Star
58204 Points
15661 Posts
Re: ASPNETCORE_ENVIRONMENT Development- Production problems
May 16, 2020 03:58 PM|bruce (sqlwork.com)|LINK
The error is saying if you enable developer mode, a more detailed error page will display (if you keep that code), not that setting the mode will fix the error.
Member
29 Points
162 Posts
Re: ASPNETCORE_ENVIRONMENT Development- Production problems
May 16, 2020 09:07 PM|Norkle|LINK
The problem is, the error occurs when I run it LIVE (after web publish) on the remote server. I do not get this error when running on localhost. So this is where the confusion lies
All-Star
58204 Points
15661 Posts
Re: ASPNETCORE_ENVIRONMENT Development- Production problems
May 16, 2020 09:28 PM|bruce (sqlwork.com)|LINK
It appears you did not write proper error logging, so you could understand errors generated in production. Ione issue is that you can only get full stack trace from a debug build. Just deploy a debug build, and if you don’t know how to set dev mode, just take the if statement out and force the developer debug page.
but you should really add error logging.
Member
62 Points
180 Posts
Re: ASPNETCORE_ENVIRONMENT Development- Production problems
May 17, 2020 06:54 AM|musbah7@hotmail.com|LINK
Go to IIS Manager > Select your published web app. > Configuration editor > Edit environmentVariables > set these values:
name: ASPNETCORE_ENVIRONMENT
value: Development
This will solve your problem.
Member
29 Points
162 Posts
Re: ASPNETCORE_ENVIRONMENT Development- Production problems
May 18, 2020 07:25 PM|Norkle|LINK
Thanks .. I don't have this type of IIS access to my sites on the shared hosting (smarterasp.net )
??
Ned
All-Star
53041 Points
23626 Posts
Re: ASPNETCORE_ENVIRONMENT Development- Production problems
May 18, 2020 07:44 PM|mgebhard|LINK
The concept is very simple. Run the application in development mode so you can see the error.
You can force developer mode in the startup.cs file as recommended above. This requires a deployment but that should not be an issue. since the application is not working
//if (env.IsDevelopment()) //{ // app.UseDeveloperExceptionPage(); //} //else //{ // app.UseExceptionHandler("/Home/Error"); // // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. // app.UseHsts(); //} app.UseDeveloperExceptionPage();
You can set development mode in the web.config.
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-3.1#set-environment-variables
Environment Reference docs
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1#set-the-environment