HTTP 403 Forbidden: Access is denied ASP.NET Web API

前端 未结 6 487
野趣味
野趣味 2021-01-12 01:54

I\'m getting the following error when running our ASP.NET Web API project on our production server.

403 - Forbidden: Access is denied. You do not hav

相关标签:
6条回答
  • 2021-01-12 02:28

    We missed deployment configuration, application pool associated with the application not exists. I created an application pool with the same name and this error has gone away.

    0 讨论(0)
  • 2021-01-12 02:29

    In my case, someone deleted default Asp Net MVC Home/Index route in RouteConfig.

    After placing this code back to the RouteConfig.cs in RegisterRoutes method the problem was gone.

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    
    0 讨论(0)
  • 2021-01-12 02:30

    The above error will pop up when you do not have the permission to access the folder/web.config file.

    Try the following

    1. In Windows Explorer, locate the web.config file that is associated with the application.
    2. Right-click the web.config file
    3. Click Properties.
    4. Click the Security tab, and then click Edit.
    5. Click Add.
    6. In the Enter the object names to select box, IUSR, click Check Names, and then click OK.
    7. Provide Full control, and then click OK.
    8. In the Web.config Properties dialog box, click OK.

    I think it should work .

    0 讨论(0)
  • 2021-01-12 02:41

    I recently faced same issue while configuring my site on iis (https). In my case, tried several solutions like:

    1. Folder security and access rights, I gave IIS_USER access even to test gave everyone access on deployed folder also change IIS permission but no luck.
    2. Enabled "Directory Browsing" but no luck
    3. Enabled "Anonymous Authentication" but no luck
    4. Reinstall https SSL certificate since using https but no luck

    and several hit and try and at last I found!!!!

    It was very tiny problem I choose "Precompile during publishing" while publishing my website/APIs and when i unchecked this option everything become normal and start working fine, not sure actual reason why this happen but to resolve you may try as showing in picture (visual studio 2019) below:

    0 讨论(0)
  • 2021-01-12 02:51

    You can follow this approach while deploying the application to production environment.

    1. Publish the application in release mode.
    2. Put your application in inetpub -- wwwroot folder because this folder have administrator rights.

    Hopefully it should run.

    0 讨论(0)
  • 2021-01-12 02:51

    In case it helps anyone my issue was my publish options set to "Allow precompiled site to be updatable" and I was missing the file "PrecompiledApp.config" in my deployed API.

    0 讨论(0)
提交回复
热议问题