1

As per the postman or web to check API as in the local environment it works. But as I update my launchSettings.json with "ASPNETCORE_ENVIRONMENT": "Production" from "Development" in two places as per the image location path below.
enter image description here

And added in configuration setting new application setting of Azure Application Settings as per research over the websites.
enter image description here Here are some websites which i referred to for solutions.

  1. https://github.com/MicrosoftDocs/azure-docs/issues/29976
  2. How and where to define an environment variable on Azure
  3. ASP.NET Core deployment to IIS error: Development environment should not be enabled in deployed applications

Still, it shows me error on postman when I check Web API after hitting the URL.

<div class="container">
            <main role="main" class="pb-3">
                <h1 class="text-danger">Error.</h1>
                <h2 class="text-danger">An error occurred while processing your request.</h2>
                <p>
                    <strong>Request ID:</strong>
                    <code>|14a7ad86-47801a7069301d42.</code>
                </p>
                <h3>Development Mode</h3>
                <p>
    Swapping to 
                    <strong>Development</strong> environment will display more detailed information about the error that occurred.
                </p>
                <p>
                    <strong>The Development environment shouldn't be enabled for deployed applications.</strong>
    It can result in displaying sensitive information from exceptions to end users.
    For local debugging, enable the
                    <strong>Development</strong> environment by setting the
                    <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to
                    <strong>Development</strong>
    and restarting the app.
                </p>
            </main>
        </div>

Update 1:-
This Url for Web Api is working.
https://kerisuiteapp.azurewebsites.net/Staff/StaffTest
Here is my code which i used.

    [AllowAnonymous]
    [HttpGet("StaffTest")]
    public IActionResult StaffTest()
    {
        var test = new { name = "joy", number = "123123123", Fax = "234234" 
                       };
        return Json(test);
    }

But this shows me error.
https://kerisuiteapp.azurewebsites.net/Staff/GetStaff
Here is the code which is not working on Azure.

    [AllowAnonymous]
            [HttpGet("GetStaff")]
            public IActionResult Staff()
            {
                try
                {
                    var staffModel = _StaffService.GetStaff();
    
                    return Ok(staffModel);
                }
                catch (Exception ex)
                {
                    return Json(ex);
                }
            }

public List<Staff> GetStaff(){
            return uow.Repository<Staff>().Get();
        }
Naman Kumar
  • 583
  • 1
  • 5
  • 16
  • I think you might be getting confused: the error tells you that you are *not* in Development mode, and you can see more information if you switch to Development mode. It seems you want to run in Production mode and that's what's happening. The error is happening for a reason that's probably unrelated. Check your connection strings. – omajid Jul 31 '20 at 21:16
  • @omajid as i have tested a dummy API it gives result https://kerisuiteapp.azurewebsites.net/Staff/StaffTest it has json result only hard coded. – Naman Kumar Aug 01 '20 at 07:12
  • @omajid but as i try to connect to Web Api which has DB connection it shows me this error. – Naman Kumar Aug 01 '20 at 07:16
  • @NamanKumar It's hard to understand what you are talking about. – Jason Aug 03 '20 at 02:07
  • @NamanKumar I think you should have a problem in the code of `var staffModel = _StaffService.GetStaff();`. – Jason Aug 03 '20 at 02:08
  • @NamanKumar Please provide more information about this code. For example, if it is running normally in your local area, then provide the database connection string format (pay attention to protect confidential information). – Jason Aug 03 '20 at 02:10
  • @NamanKumar According to your instructions, the value of `ASPNETCORE_ENVIRONMENT` was modified. I think the problem is not here. The error message prompts you to modify, but it is nothing more than to let you see more error messages. – Jason Aug 03 '20 at 02:11
  • @NamanKumar You can try according to my answer first. If it is indeed possible to exclude the database connection error, it is recommended to use remote debug to troubleshoot the problem. If you have any questions, I look forward to your reply. – Jason Aug 03 '20 at 02:29
  • Has your problem been solved? – Jason Aug 07 '20 at 09:36
  • @JasonPan in the RDP my colleague put the project inside inetpub/wwwroot folder as i was putting in some other folder inside the C: drive so it worked i suppose that was the problem. – Naman Kumar Aug 07 '20 at 14:18

0 Answers0