locked
Multiple ASP.NET Core Sub-Applications Targeting .NET Framework Under a Main Site RRS feed

  • Question

  • User477065142 posted

    I have multiple .NET Core applications that are all the same but higher versions have more features and bug fixes. They target the .NET Framework 4.6.2.

    Suppose the apps are named App1, App2, and App3, where App3 is the latest version of App. I am trying to configure a website that can host App1, App2, and App3 as sub-applications so that the URL can be something like this when browsing from IIS: http://mainSite/App1, http://mainSite/App2, and http://mainSite/App3. The default page displayed by each application is the logo and the version of the app. All apps are under the default wwwroot folder of IIS.

    Here is what I tried:

    • Having a default.aspx page as the main site, but the sub-apps cannot find the route I specify in their URLs, e.g. http://mySite.com/App1/open. This setup does not seem to be able to handle virtual routes (I am not sure if they are called virtual routes, but essentially they are defined with the Route attribute like [Route("open/template")] in the back-end and handled in Angular with /open/template in the front-end).
    • Hosting App1 and App2 under App3. That is, App1 and App2 are sub-apps of App3. App3 opens fine and requests are routed properly. After some researching, I also disabled the inheritance of the parent web.config to the sub-apps and I also changed the base href attribute in the index.html of App1 and App2 to /App1/ and /App2/. Calling http://mainSite/App1 shows the proper version of App1 since it's now using its own static files. However, http://mySite.com/App1/open routes to App3's "open" route. This means that http://mainSite/App1/open redirects to http://mainSite/open/template instead of http://mainSite/App1/open/template. In addition, I tried using different Application Pools with No Managed Code. This is the closest I could get to solve my problem.
    • Hosting the sub-apps using the In-Process model. But later found out it's impossible since they target .NET Framework. https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1

    Other people seem to have this figured out, but I am not sure if it's because they are developing .NET Core apps that target .NET Core rather than .NET Framework or something else.

    Is there a way to configure IIS such that the sub-apps can use their own roots (http://mainSite/App1/ and http://mainSite/App2/) instead of using the parent root at http://mainSite/?

    I am trying my best to not change anything in the code because it is not implemented by me and it might require changes in previous versions of the app too.

    According to https://forums.asp.net/post/6294789.aspx, what I want to achieve does not seem doable...

    Any help is appreciated, thank you.

    Tuesday, March 3, 2020 9:04 PM

All replies

  • User475983607 posted

    helenhxtam

    Is there a way to configure IIS such that the sub-apps can use their own roots (http://mainSite/App1/ and http://mainSite/App2/) instead of using the parent root at http://mainSite/?

    Create a main site and leave it empty.  Within the main site create virtual directories or applications; app1, app2, app3, etc.   

    helenhxtam

    I am trying my best to not change anything in the code because it is not implemented by me and it might require changes in previous versions of the app too.

    You should consider using source control.   It's free.  See GIT and github.com.

    https://git-scm.com/

    https://github.com/

    Tuesday, March 3, 2020 9:28 PM
  • User477065142 posted

    Thank you for the reply.

    I probably should have provided more context. The main site should preferably not be empty because this will be deployed to production within my team and to clients as well. Clients access our applications via different ports and we cannot keep asking them to open a new port when we deploy a new version of the application. Older versions will be kept since they meet needs that cannot be met in newer versions.

    Create a main site and leave it empty

    The routing is still wrong when I tried this. I browsed http://localhost:9999/App1/open and it's still calling the parent http://localhost:9999/open/template rather than http://localhost:9999/App1/open/template. A 404 - Not Found error was thrown and I noticed that it was trying to access the requested web page from the main site's physical path at C:\inetpub\wwwroot\emptySite\ when it should really be looking at C:\inetpub\wwwroot\App1\.

    Also, the source code is hosted on Azure DevOps as a TFVC repository. The main issue with modifying the code is that previous versions of the application has already been deployed to production and are used by clients. We are keeping this as our very last option if nothing else can be done outside of the source code. What's important is to have the sub-apps working under a single main site.

    Wednesday, March 4, 2020 4:35 PM