Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SessionServer returns 404 from .net framework, help needed #569

Open
lkneat opened this issue Dec 19, 2024 · 5 comments
Open

SessionServer returns 404 from .net framework, help needed #569

lkneat opened this issue Dec 19, 2024 · 5 comments
Labels
Needs: Attention 👋 Issues and PRs that the maintainers should take a look at

Comments

@lkneat
Copy link

lkneat commented Dec 19, 2024

I'm hoping I've missed something simple here. Our .net framework app is using Unity DI which may be related to the issue. I see exceptions from Unity being unable to resolve constructors for things like System.Web.Http.Dispatcher.IAssembliesResolver but I believe these are red herrings as the services used internally in systemweb-adapters should fallback to default services when null is returned?

The setup for sessionserver in Global.asax.cs Application_Start is as follows. I've tried with and without proxy support options and many different endpoints. We have a redirect set up for any unknown request not starting in /api so I haven't tested the default of /systemweb-adapters/session

I'm unable to access the /api/test, either from .net core or directly myself to see if the endpoint is live. Our .net core app is running in a docker container on 443 and the .net framework app is on IIS on windows on 32773. The .net framework app is hosted on a virtual directory subfolder so the site structure is a website called 'app' with a virtual directory called 'app' which is where the site lives.

I've tried setting the basepath in the container to '/app' as well as I saw something about mirroring virtual directories but with no success. I don't see any sort of relevant error in the logs for .net framework.

Any help on this would be greatly appreciated

   SystemWebAdapterConfiguration.AddSystemWebAdapters(this)
            .AddSessionSerializer()
            .AddProxySupport(options =>
               {
                  options.ServerPort = 32773;
                  options.UseForwardedHeaders = true;
                  options.Scheme = "https";
               }
               )
            .AddJsonSessionSerializer(options =>
            {
               // Register every session key here
               options.RegisterKey<string>("TestKey");
            })
            .AddRemoteAppServer(options => { options.ApiKey = "54b69938-90dd-4f79-adcd-27fbd6f0e4b7"; })
            .AddSessionServer(options =>
            {
               options.SessionEndpointPath = "/api/test";
            });
@dotnet-policy-service dotnet-policy-service bot added the Needs: Triage 🔍 Label added to new issues which need Triage label Dec 19, 2024
@lkneat lkneat changed the title SessionServer returns 404 from .net framework SessionServer returns 404 from .net framework, help needed Dec 19, 2024
@twsouthwick
Copy link
Member

It's probably because the virtual directories must be the same; see docs.

@twsouthwick twsouthwick added Needs: Author Feedback Issues and PRs that are waiting on the author's response and removed Needs: Triage 🔍 Label added to new issues which need Triage labels Jan 6, 2025
@lkneat
Copy link
Author

lkneat commented Jan 13, 2025

Thanks so much for the reply Taylor.

Is there more documentation on exactly how mirrored the virtual directories need to be and is there a tool or method to see if they do match? Any guidance on figuring this out, whether it be using an IDE debugger or looking for a particular error message in the log, would be greatly appreciated.

If it's not possible to do so would you be able to answer any of the questions below? Apologies if some of these are very common knowledge, most of my experience is outside of the MS stack

  • Right now we proxy nearly everything to the .net framework application, should there be empty directories within the .net core application for things being proxied?
  • In the case of web.config files within subdirectories should these be mirrored on the linux container or is it just the virtual directory structure? If they should be mirrored does that include within empty directories ( if above is true )
  • Should top level site folders like App_Data be mirrored or just those within the application? For clarity our site layout in IIS is
 website
      app_data
      aspnet_client
      application
        appfolder1
        appfolder2
  • Is it ok to have new folders not present on the .net framework application or would that break the code (eg. test endpoint for the .net core application)

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 Issues and PRs that the maintainers should take a look at and removed Needs: Author Feedback Issues and PRs that are waiting on the author's response labels Jan 13, 2025
@twsouthwick
Copy link
Member

@lkneat I was referring to IIS virtual directories: https://learn.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis. That structure needs to be the same for both core and framework applications.

ASP.NET Core doesn't care about the folders you have and won't affect anything. The reverse proxy will serve things from ASP.NET Core if the route exists (however you want to serve that) then proxy back to the ASP.NET Framework app

@lkneat
Copy link
Author

lkneat commented Jan 15, 2025

@twsouthwick Thanks Taylor, to clarify our .net framework app is running on IIS in windows, however our .net core app that we are migrating to is running in an Alpine Linux image so there isn't a virtual directory if I understand correctly.

Is the underlying assumption that the endpoints that we proxy to must match up in the virtual directory ( i.e. if I try to access resource1 at /endpoint1/resource1 and it's not in .net core then yarp should be proxying to a .net framework app where resource1 is in endpoint1 in the virtual directory)

Or is the problem that there are other underlying architectural constraints that mean both .net core and .net framework must be running on IIS and use virtual directories?

@twsouthwick
Copy link
Member

Is the underlying assumption that the endpoints that we proxy to must match up in the virtual directory ( i.e. if I try to access resource1 at /endpoint1/resource1 and it's not in .net core then yarp should be proxying to a .net framework app where resource1 is in endpoint1 in the virtual directory)

Yes, although I believe it's a bit more nuanced. If you're running on virtual directories on the framework app, it's tricky to make things work right (asp.net framework just doesn't have the right hooks to map things) if you're on Kestrel.

Or is the problem that there are other underlying architectural constraints that mean both .net core and .net framework must be running on IIS and use virtual directories?

No - .net core can be hosted on any server you want (http.sys, iis, or kestrel)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention 👋 Issues and PRs that the maintainers should take a look at
Projects
None yet
Development

No branches or pull requests

2 participants