1

I'm a new in linux. But I need to run asp net core app at this os. I build and compile app successfuly in windows 10, but when I move this to linux and try to run get following exception

Application startup exception: System.TypeInitializationException: The type initializer for 'Microsoft.AspNetCore.Server.HttpSys.HttpApi' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'httpapi.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libhttpapi.dll: cannot open shared object file: No such file or directory
   at Microsoft.AspNetCore.Server.HttpSys.HttpApi.HttpInitialize(HTTPAPI_VERSION version, UInt32 flags, Void* pReserved)   at Microsoft.AspNetCore.Server.HttpSys.HttpApi.InitHttpApi(UInt16 majorVersion, UInt16 minorVersion)
   at Microsoft.AspNetCore.Server.HttpSys.HttpApi..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.HttpSys.HttpSysListener..ctor(HttpSysOptions options, ILoggerFactory loggerFactory)
   at Microsoft.AspNetCore.Server.HttpSys.MessagePump..ctor(IOptions`1 options, ILoggerFactory loggerFactory, IAuthenticationSchemeProvider authentication)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureServer()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

And I really need to use httpSys driver. That is in my code

 public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseHttpSys();
Ilya
  • 45
  • 1
  • 8

1 Answers1

1

You can't run Http.sys on Linux, its a windows only hosting option.See the documentation.

Http.sys is tightly coupled to windows (and IIS, which is the Microsoft Webserver).

For Linux you have to use Kestrel.

Tseng
  • 61,549
  • 15
  • 193
  • 205
  • Thanks! It's really my bad Dear friend, could you recommend me a way to launch my app on https://localhost/ (:433 port). Kestrel writes : Unable to start Kestrel. System.IO.IOException: Failed to bind to address https://localhost:443. ---> System.AggregateException: One or more errors occurred – Ilya Jan 17 '19 at 12:27
  • Run it as root. Linux requires root privileges for ports lower than 1024. Or use a higher port and do port mapping on that one – Tseng Jan 17 '19 at 12:30
  • Yup, it works. But only with single port (:443) I get exception {System.IO.IOException: Failed to bind to address localhost:443 Why it fails with default port? – Ilya Jan 17 '19 at 12:58
  • Something else running on that port? You can only bind one application on that port. Typically you run ASP.NET Core applications on a high port, >=5000 and use nginx (or nginx + docker for both app and nginx) as reverse proxy to your application. But thats a separate question on it own – Tseng Jan 17 '19 at 13:12
  • There is a web site that binded to this port. It should send requests to my asp app – Ilya Jan 17 '19 at 13:29