Post requests do not work in production after deploy

Farid GN 1 Reputation point

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?

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

4 answers

Sort by: Most helpful
  1. AgaveJoe 26,031 Reputation points

    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.

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

    0 comments No comments

  2. Bruce ( 54,621 Reputation points

    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 2,716 Reputation points Microsoft Vendor

    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, 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
    0 comments No comments

  4. Farid GN 1 Reputation point

    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\\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