Windows IIS server 403 error for ASP.NET CORE Web API

fako 0 Reputation points
2023-05-04T20:31:12.59+00:00

Hello. In my windows server and in iis server there are two web sites. First is working fine on 443 port and ı add second one for asp.net core web api. I directed a subdomain to my web api via cloudflare. like https://api.example.com. my api folder in Inetpub\wwwroot\sample. When I try to connect https://api.example.com/api/test IIS giving 403 error. How can ı fix it? I add permission all user for sample folder.

Windows development Internet Information Services
Developer technologies ASP.NET ASP.NET Core
Windows for business Windows Server User experience Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Sam Wu-MSFT 7,561 Reputation points Microsoft External Staff
    2023-05-05T07:46:01.6866667+00:00

    @fako

    There are many reasons for 403 error, usually this is a permission error issue, but you have tried adding sufficient permissions to the folder, in addition, you can also try the following solutions:

    1. Open Internet Information Services Manager
    2. In the Connections pane, expand the server name, and then go to the website where you want to enable directory browsing.
    3. In the Home pane, double-click Directory Browsing.
    4. In the Actions pane, click Enable.

    If that doesn't work, you can use failed request tracking to view detailed error information.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Limitless Technology 44,746 Reputation points
    2023-05-05T17:39:01.19+00:00

    Hello there,

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

    Try the following

    In Windows Explorer, locate the web.config file that is associated with the application.

    Right-click the web.config file

    Click Properties.

    Click the Security tab, and then click Edit.

    Click Add.

    In the Enter the object names to select box, IUSR, click Check Names, and then click OK.

    Provide Full control, and then click OK.

    In the Web.config Properties dialog box, click OK.

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

  3. Lex Li (Microsoft) 6,037 Reputation points Microsoft Employee
    2023-05-06T19:31:28.2+00:00

    When you wrote an ASP.NET Core Web API project, the URLs it serves must follow the convention unless you change the default routing rules. So /api/test is in general invalid and 403 is expected. Please study ASP.NET Core routing from articles like this.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.