Blazor Server Application - How to Deploy to IIS

Cenk 956 Reputation points
2022-09-05T14:57:00.677+00:00

Hello guys,

Finally, we have come to that blessed moment, it is time to reap the fruits of our work. I want to deploy my Blazor Server application to my test server on the cloud. Please guide me on this.

Thank you in advance.

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,385 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 55,601 Reputation points
    2022-09-05T16:23:05.27+00:00

    Deploy like any asp.net core site. Your cloud host must support .net core apps, and should have docs for deployment. A windows host my support WebDeploy, or you may need to ftp.

    https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/?view=aspnetcore-6.0

    0 comments No comments

  2. Cenk 956 Reputation points
    2022-09-05T19:24:28.163+00:00

    I am getting this error,

    HTTP Error 500.30 - ASP.NET Core app failed to start  
    

    I checked the event viewer, the error detail is

    Application: w3wp.exe  
    CoreCLR Version: 6.0.822.36306  
    .NET Version: 6.0.8  
    Description: The process was terminated due to an unhandled exception.  
    Exception Info: System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')  
       at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)  
       at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 sqlServerOptionsAction)  
       at Program.<>c__DisplayClass0_0.<<Main>$>b__2(DbContextOptionsBuilder options) in C:\Users\197199\Source\Repos\IMS.WebApp\IMS.WebApp\Program.cs:line 45  
       at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass12_0`2.<AddDbContextFactory>b__0(IServiceProvider p, DbContextOptionsBuilder b)  
       at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.CreateDbContextOptions[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)  
       at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass17_0`1.<AddCoreServices>b__0(IServiceProvider p)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)  
       at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)  
       at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)  
       at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)  
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)  
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)  
       at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__17`1.<AddCoreServices>b__17_1(IServiceProvider p)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)  
       at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)  
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)  
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)  
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)  
       at Program.<Main>$(String[] args) in C:\Users\197199\Source\Repos\IMS.WebApp\IMS.WebApp\Program.cs:line 116  
      
    

    Is there an easy way to create database and tables on the test server on cloud? On my local machine it is SQL express.


  3. Bruce (SqlWork.com) 55,601 Reputation points
    2022-09-06T00:58:05.523+00:00

    Looks deployed correctly. Just a startup error connecting to the database. You hosting provider should support different database engines. Pick and configure one, then be sure you pick one that EF support and build with the correct driver. Typically ally when you configure you database in the cloud, the configuration includes the connection string.

    0 comments No comments

  4. Cenk 956 Reputation points
    2022-09-06T04:38:23.343+00:00

    It is Windows Server 2012 and SQL Server 2017 on top of it. Is there a practical way to create tables on it via EF Core? Or should I create them manually by creating scripts? Is there a step-by-step guide to creating tables and applying migrations to the remote database?


  5. Cenk 956 Reputation points
    2022-09-06T15:35:50.563+00:00

    It is not Azure, a virtual server on the hosting cloud.

    0 comments No comments