Deploying a Blazor server .NET 5 application as a sub application to another .NET 5 application

NT 1 Reputation point

I have a .NET 5 Blazor Server application with signalr integration and it works fine when hosted on its own but I want it to be used as "" if "" is the address of the main application. The folder for the newapp is located in a folder separate from the main application like "C:\inetpub\wwwroot\NewApp" and on its own app pool. The web.config for the sub-app is like this

<?xml version="1.0" encoding="utf-8"?>
  <location path="." inheritInChildApplications="false">
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      <aspNetCore processPath=".\newapp.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
          <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />

When I try to go to "", the page keeps on spinning and doesn't load. I also have other .NET framework sub applications running on it but they run fine when I go to "".

Since I don't have the directory for the Blazor app under main app, I didn't make any changes to the <base href="~/"> in _Host.cshtml or add app.UsePathBase("/NewApp") in Startup.cs. I added webBuilder.UseKestrel(); webBuilder.UseIISIntegration(); webBuilder.UseStartup<Startup>(); webBuilder.UseIIS(); in my program.cs and it doesn't work either.

I have checked the logs in Event Viewer and there are no errors. I tried to upload the basic Blazor app without any signalr integration and that works. Is the sub-app structure unable to hit the signalr Hub class?

Is there anything I am missing?

Internet Information Services
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,413 questions
A set of technologies in the .NET Framework for building web applications and XML web services.
3,306 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce Zhang-MSFT 3,736 Reputation points

    Hi @NT ,

    You need to add a href in index.razor. Change @page "/" to @page "/newapp/". Then you can get a page from IIS.


    However, you'd better not do that. It will cause more issues which are difficult to find a great solution. Because the application contains blazor route, signalr route and IIS route. If you add more functions and url paths to the example app in the documentation, if one of them fails, you will have a hard time troubleshooting which route is causing the problem.

    The best choice is setting it as a site on IIS, not sub application under site.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Bruce Zhang