Post requests do not work in production after deploy

Farid GN 1 Reputation point
2024-02-27T20:05:30.2366667+00:00

Hi, I have a classified ads web application developed in ASP.NET Core 2.1, and it works well from localhost. No issue with get and post requests. But after deploying the application into server, though website is published successfully, I cannot create or edit any posts. When I do the same in localhost, the post is created, and all relevant data is stored in the database of the server for appropriate table. But when I create my ad post in my deployed website, it returns the error familiar to all of you: An error occurred while processing your request. ***Request ID: *0HN1NPJI6V70V:0000000C Development Mode Swapping to Development environment will display more detailed information about the error that occurred. But actually, no issue is seen in development mode as I explained above, I even debugged from local though there was no need to do as it worked perfectly. I contacted my hosting server, but they still cannot find solution to it. I'd like to add that I previously hosted this website in the same hosting and it was working fine, so there was no issue with version compatibility. Any good idea what may be the reason. Do I need to change configuration in web.config to something in files folder?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,400 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. AgaveJoe 27,696 Reputation points
    2024-02-27T20:46:22.2766667+00:00

    Follow the instructions in the error message and set the application to development environment on the server. Probably the easiest is updating the web.config file on the server. https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/web-config?view=aspnetcore-8.0#set-environment-variables

    https://stackoverflow.com/questions/41546943/how-to-set-aspnetcore-environment-to-be-considered-for-publishing-an-asp-net-cor

    https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-8.0

    ASP.NET Core 2.1 is no longer supported. You should move to a newer LTS version.

    0 comments No comments

  2. Bruce (SqlWork.com) 61,731 Reputation points
    2024-02-28T03:06:33.3+00:00

    Any unhandled error can be causing this. Most likely it’s database access or permissions. You could add a test page, which has proper error handling and reporting, test connection, read, write and stored proc access.

    0 comments No comments

  3. Brando Zhang-MSFT 3,446 Reputation points Microsoft Vendor
    2024-02-28T09:28:48.41+00:00

    Hi @Farid GN, Welcome to the Q&A forum. There are a lot of errors which will casue this issue, so we need to know the details error message. Since in production environment, asp.net core application has the default setting to ignore the details error message, we should open the settings or log the details error. Normally, we have below 3 ways to check it. 1.Enable the stdlogs to see the details error message by modify the web.config's settings like below and check the .\logs\stdout file:

          <aspNetCore processPath="dotnet" 
          arguments=".\WebApplication1.dll" stdoutLogEnabled="true"  stdoutLogFile=".\logs\stdout" hostingModel="inprocess"/>
    

    2.Change the environment Variable inside the web.config to Development to see the details error message.

       <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
    
    
    1. Change the codes to see the details error message in startup.cs
    app.UseDeveloperExceptionPage();
    
    0 comments No comments

  4. Farid GN 1 Reputation point
    2024-02-28T09:58:47.3666667+00:00

    Thank you guys for your answers. I've changed ASPnetEnvironment from Production to Development in web.config file, and finally, I could see the detailed error in publish mode.
    It's UnauthorizedAccessException: Access to the path 'C:\Inetpub\vhosts\endirimli.az\httpdocs\wwwroot\images\aloe_logo.png' is denied. You can see the details in the attached. As seen, the error comes from server side as it's working fine from my local host. Seems something happens that interrupts image to be uploaded. I addressed web hosting team to review and give relevant access. If you have any good idea, I'd be glad to hear from you and would help them if they fail to fix the problem. accessdeny.png