getting an error when trying to browse my site on IIS

Socks93

Active member
Joined
Oct 22, 2021
Messages
30
Programming Experience
Beginner
Hi,

When attempting to browse my site on IIS i get the following error:

1676489643804.png


web config file:

C#:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\Cms12.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>


I have downloaded the windows bundle installer for .Net 6.0, I have also changed the module from AspNetCoreModule2 to AspNetCoreModule as this was something that some people did to fix the issue but i still get the same error.

Does anyone have any suggestions as to why this is occuring?

Thankyou
 
For .NET 6.0, the process path should be pointing to your .exe, not to "dotnet" passing in your DLL.

Make sure that your build is really targeting .NET 6.0.

Make sure to do a clean publish.

Make sure to use the web.config file from the publish directory.
 
For .NET 6.0, the process path should be pointing to your .exe, not to "dotnet" passing in your DLL.

Make sure that your build is really targeting .NET 6.0.

Make sure to do a clean publish.

Make sure to use the web.config file from the publish directory.

@Skydiver thankyou for the prompt response. The build is targeting .Net 6.0. I've gone into the properties > application tab > general and the target framework is .Net 6.0

I did another dotnet publish:

1676496530911.png


I have used the publish link in IIS for the Physical path:

1676496584190.png


The exe file is also within in same path:
1676496636847.png


I have now added the path for the .exe file as shown below:

C#:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="C:\cms12\Cms12\bin\Debug\net6.0\Cms12.exe" arguments=".\Cms12.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>

However im still getting the same error
 
Last edited:
Forgive me. I'm so use to having the teams that I support always build self-contained rather than framework dependent that I've forgotten that framework dependent builds web.configs do not point directly to the .exe. Framework dependent build point to "dotnet".

Looking back at your post #2, this line:
XML:
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule2" resourceType="Unspecified" />
should look like:
XML:
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
 
Anyway, if you have access to the IIS box, one other diagnostics that we do is simply try to run the web app from the command line. So in your case:
Code:
dotnet .\Cms12.dll

You may discover that you are missing some dependencies, or that the server has a different version installed compared to the version that you built against.
 
Anyway, if you have access to the IIS box, one other diagnostics that we do is simply try to run the web app from the command line. So in your case:
Code:
dotnet .\Cms12.dll

You may discover that you are missing some dependencies, or that the server has a different version installed compared to the version that you built against.

Hi @Skydiver

Its giving me the following error, and I'm not too sure why its saying this:

C#:
C:\cms12\Cms12\bin\Debug\net6.0\publish>dotnet .\Cms12.dll
Unhandled exception. System.IO.IOException: Failed to bind to address http://[::]:8000: address already in use.
 ---> Microsoft.AspNetCore.Connections.AddressInUseException: Only one usage of each socket address (protocol/network address/port) is normally permitted.
 ---> System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions.CreateDefaultBoundListenSocket(EndPoint endpoint)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TransportManager.BindAsync(EndPoint endPoint, ConnectionDelegate connectionDelegate, EndpointConfig endpointConfig, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<>c__DisplayClass30_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.AnyIPListenOptions.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at Cms12.Program.Main(String[] args) in C:\cms12\Cms12\Program.cs:line 19
fail: EPiServer.Scheduler.Internal.SchedulerService[0]
      Failed reading next item
      System.ObjectDisposedException: Cannot access a disposed object.
      Object name: 'IServiceProvider'.
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
         at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
         at EPiServer.Data.DataInitialization.<>c__DisplayClass6_1.<ConfigureContainer>b__8()
         at EPiServer.DataAccess.Internal.SchedulerDB.List()
         at EPiServer.DataAbstraction.Internal.DefaultScheduledJobRepository.List()
         at EPiServer.Scheduler.Internal.SchedulerService.GetNextScheduledJob()
         at EPiServer.Scheduler.Internal.SchedulerService.ReadNextScheduledItem()
      System.ObjectDisposedException: Cannot access a disposed object.
      Object name: 'IServiceProvider'.
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
         at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
         at EPiServer.Data.DataInitialization.<>c__DisplayClass6_1.<ConfigureContainer>b__8()
         at EPiServer.DataAccess.Internal.SchedulerDB.List()
         at EPiServer.DataAbstraction.Internal.DefaultScheduledJobRepository.List()
         at EPiServer.Scheduler.Internal.SchedulerService.GetNextScheduledJob()
         at EPiServer.Scheduler.Internal.SchedulerService.ReadNextScheduledItem()


appsettings.development.json

C#:
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "EPiServer": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "urls": "http://*:8000/;https://*:8001/;",
  "AllowedHosts": "*"
}

appsettings.json

C#:
{
  "Logging": {
    "LogLevel": {
      "Default": "Warning",
      "Microsoft": "Warning",
      "EPiServer": "Warning",
      "Microsoft.Hosting.Lifetime": "Warning"
    }
  },
  "urls": "http://*:8000/;https://*:8001/;",
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "EPiServerDB": "Server=(localdb)\\MSSQLLocalDB;Database=EPiServerDB_eeb5452d;User Id=EPiServerDB_eeb5452dUser;Password=9uywu2dJUZ7najkO7$7;TrustServerCertificate=True"
  }
}

Program.cs

C#:
namespace Cms12
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
            var isDevelopment = environment == Environments.Development;

            if (isDevelopment)
            {
                //Development configuration
            }

            CreateHostBuilder(args, isDevelopment).Build().Run();
        }

Thank you
 

Attachments

  • 1676532962195.png
    1676532962195.png
    11.5 KB · Views: 31
Last edited:
Well, that's a new one. I've not seen that before. It seems like something is blocking you from binding to port 8000. Some AV software does this to block common vectors, but I recommend checking to see if you have other .NET Core apps currently running, since .NET Core apps tend to have a preference to grab that port.
 
Restart your machine and run only this project?

Waht does your applicationHost.config look like?
 

Latest posts

Back
Top Bottom