0

i created a new ASP.NET Core 2.1 Web Application using the Angular Template.

Ran locally in both Debug and Release mode with success.

Created a publish profile to file system, it published successfully to a local folder.

installed: .NET Core 2.1 Runtime & Hosting Bundle for Windows Then in IIS,

  1. Created a new Application pool- that uses .net CLR = "No Managed Code"
  2. Then under Default Web Site > created new application that uses the new application pool that i have created, and point to the file-system, to the published directory that published with the help of VS 2017

when i Browse to the appliction, this message appear in the browser enter image description here

So in web.config file i changed, environmentVariable to Development in order to see the error

 <aspNetCore processPath="dotnet" arguments=".\WebApplication1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
    <environmentVariables>
      <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
    </environmentVariables>
  </aspNetCore>

Then i see the error enter image description here

I have no clue on what to do next, i have already tried to search for solutions for that, on Stack-overflow and Google here, here and a lot more.

when i am setting stdoutLogEnabled to true in web.config, then i see this in the logs of the application

Hosting environment: Production Content root path: C:\prodSites\beedeal Now listening on: http://127.0.0.1:26261 Application started. Press Ctrl+C to shut down. warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware3 Failed to determine the https port for redirect. fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware1 An unhandled exception has occurred while executing the request. System.InvalidOperationException: The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request. Your application is running in Production mode, so make sure it has been published, or that you have built your SPA manually. Alternatively you may wish to switch to the Development environment.

at Microsoft.AspNetCore.SpaServices.SpaDefaultPageMiddleware.<>c__DisplayClass0_0.b__1(HttpContext context, Func`1 next) at Microsoft.AspNetCore.Builder.UseExtensions.<>c__DisplayClass0_1.b__1(HttpContext context) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)

but didn't find a solution for that..

E.Meir
  • 2,146
  • 7
  • 34
  • 52
  • There seems to be something that tries to start the angular development server (package.json > scripts > start should call something like ng start). If so, that's wrong. For production, your angular app muss be build using ng build and that will produce static files to be delivered by IIS. – Christoph Lütjen Sep 26 '18 at 14:36
  • Enable developers exception page by default and don't switch environment to dev. See what happens. – Anton Toshik Sep 26 '18 at 19:04
  • @ChristophLütjen i used Visual Studio publish process and the out put folder seems to be have static files, created in the process of publish through Visual Studio, so i am not sure what you ask.. – E.Meir Sep 26 '18 at 21:20
  • I don't know anything about IIS, I just see in your error message that it seems to try to run ng start. And this is wrong and so that's something you could check why that happens. – Christoph Lütjen Sep 27 '18 at 10:29

1 Answers1

0

followed this, i finally successfully deployed the application to IIS,

I think that the problem with my non-working try is that that i placed the new .net core site under

Default Web Site IIS folder, and for .net core application it's not allowed (you can't mix .net core application and .net framework application under the default web site folder (that was meant for .net framework applications)). .net core app uses different configuration + needs to run with no managed code application pool.

E.Meir
  • 2,146
  • 7
  • 34
  • 52