.NET Core publishing to IIS problems - 403.14

15,854

Solution 1

Make sure that the service account / user credentials set on the application pool has access to run / access the app. That was my issue when deploying to IIS a few times.

enter image description here

As for including the web.config, make sure to include the following code in your project.json file. Just specify what you want to include in the publish.

"publishOptions": {
  "include": [
    "wwwroot",
    "Views",
    "appsettings.json",
    "web.config"
  ]
}

Solution 2

Check if there is web.config in your application's folder. If there is no web.config in the folder IIS don't know it's an ASP.NET Core application, it thinks you are trying listing the file in that folder. So if you set IsTransformWebConfigDisabled property in the project configuration to true, which caused Web.config file isn't generated in the publish folder when build it. So Change the IsTransformWebConfigDisabled property to false in YourProjectName.csproj file like this:-

<IsTransformWebConfigDisabled>false</IsTransformWebConfigDisabled>
Share:
15,854
Beau D'Amore
Author by

Beau D'Amore

SOFTWARE ENGINEER, WITH 20+ years of experience committed to supporting key thought leaders in the advancement of sustainable programs and enrichment of overall operations. AREAS OF EXPERTISE Requirements Gathering Translate Business Needs Critical Thinking Priority Organization Senior Executive Collaboration Implement Design Functionality Team or Solo Capable Cloud and Legacy systems eCommerce Competency Sitecore Certified User Experience Skilled in the following: Visual Studio, C#, MVC, NET Core, WebAPI, SQL, JavaScript, JQuery, Bootstrap, Ajax, GIT, NodeJS, NightwatchJS, HTML, Jira, Azure Dev Ops, Testing Automation, AWS: EC2, RDS, S3 PROFESSIONAL EXPERIENCE Senior Programming Analyst, Vitas, Miami, FL 5/2019-present Senior Technology Developer, The Primacy, West Palm Beach, FL 5/2018-01/2019 Senior Software Engineer, Verity IQ (start-up), Boca Raton, FL 2/2018-04/2018 Software Engineer, OPENCLOSE, West Palm Beach, FL 8/2017-02/2018 .Net Engineer 2, RADIAL (Formerly eBay Enterprises), Boynton Beach, FL 10/2015-04/2017 .Net Operations Engineer, WEALTH MANAGEMENT SYSTEMS INC., West Palm Beach, FL 08/2014-04/2015 Software Engineer, TRIAGENCY, Philadelphia, PA 06/2012-01/2015 Senior Software Engineer, eDERM Systems LLC., Boca Raton, FL 03/2013-08/2013 Web Programmer, WEBIMAX.COM, Mt. Laurel, NJ &amp; South Florida 06/2011-06/2012 EDUCATION Data Processing Trainers Business School, Philadelphia, PA Client Server Programming OCCUPATIONAL CERTIFICATIONS Sitecore Certified 9.0

Updated on July 03, 2022

Comments

  • Beau D'Amore
    Beau D'Amore almost 2 years

    I am trying to publish a Core 1.0 app to a 2012R2 box that runs fine locally in IIS Express.

    • Installed DotNetCore.1.0.0-WindowsHosting.exe on server
    • Installed httpPlatformHandler_amd64.msi
    • Set app pool to have 'no managed code'
    • published from VS using 'Web Deploy'
    • Latest VS Core Tools as of this writing

    All I get is:

    HTTP Error 403.14 - Forbidden

    The Web server is configured to not list the contents of this directory.

    In this article from Microsoft it only mentions that a 403.14 Forbidden error is created by picking the wrong directory for the site... which is not the case.

    VS does NOT pusblish the web.config, however. And there is no choice for 'copy to server always' or 'content' (in DDL), both choices are missing.

  • Beau D'Amore
    Beau D'Amore over 7 years
    ok, how do I find out if the service account / user credentials set on the application pool has access to run / access the app? It is using ApplicationPoolIdentity. There are 30+ other sites running fine on this server, fyi.
  • aholtry
    aholtry over 7 years
    If you are using the 'Authorize' attribute in any of your controllers then you need to make sure that that user or group is listed in the identity of the application pool. You can set this in IIS under Application Pools -> Advanced Settings -> Identity
  • Beau D'Amore
    Beau D'Amore over 7 years
    I don't understand what you mean. 'The user or group'... do you mean the person logging in? It doesn't make sense because only one account can be the app pool identity... I guess I am not getting what you're saying... "is listed in the identity of the app pool'... you mean those users under some AD group??
  • aholtry
    aholtry over 7 years
    Correct, if they belong to an AD group then I would use the service account associated with that group as the Identity for the application pool. An easier example would be a single user. Just use their credentials for the Authorize in the controller as well as the identity in the Application Pool.
  • Beau D'Amore
    Beau D'Amore over 7 years
    The app pool identity can only be one of four things, LocalService, LocalSystem, NetworkService, ApplicationPoolIdentity.... I think we're not on the same page... thanks for your help though.
  • aholtry
    aholtry over 7 years
    Those are the built in accounts. Do you not have the option for Custom account? That is where you can specify your own account. I will post a picture of it in my answer above.
  • aholtry
    aholtry over 7 years
    Either way, I'm sorry I wasn't more helpful and I hope you get the answer you need soon.
  • aholtry
    aholtry over 7 years
    I just ran into the 403 error again myself and it turns out I was publishing to the wrong folder. So an empty folder will produce a 403 error. Just FYI
  • Beau D'Amore
    Beau D'Amore over 7 years
    I'm publishing to the right spot, just isn't working. I scrapped it. Started a fresh project with the latest core 1.0 refs, moved all the classes over, touched it up so it works with the newer libraries, fired it up fine... and STILL...CAN'T.... PUBLISH......
  • aholtry
    aholtry over 7 years
    Is your application pool running? And is your site running? They both need to be running.
  • Beau D'Amore
    Beau D'Amore over 7 years
    this isn't publishing an 'approot' folder anymore either.. just blobing it all in one folder above wwwroot
  • Beau D'Amore
    Beau D'Amore over 7 years
    I'm an idiot... I moved the IIS root folder to teh parent directory above wwwroot and now I get 'oops 500 internal server error' which means it started but had an error... thanks
  • aholtry
    aholtry over 7 years
    That's great news, sometimes we just need to talk it out. Nice work and I hope you keep having better luck.
  • Martin
    Martin over 3 years
    The web.config file is generated when you run dotnet publish --configuration Release, if you are missing that file you are most likely not running the dotnet publish command.