I have .NET Framework 4.8 ASP.NET Web Forms application. Using ashx-handlers is quite inconvenient, so I want to use .NET Core Web API (in order to switch all of my code from handlers to controllers and switch the whole app to .NET Core).
I know that attaching ASP.NET WebAPI to ASP.NET Web Forms is easy, but I’m struggling with .NET Core WebAPI, because its request pipeline is different.
Are there any ways to use .NET Core WebAPI project from existing Web Forms app as a subroute?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I don’t think that’s possible.
Targeting .net framework and .net core is a completely different thing.
I’d create two different applications and I’d use IIS UrlRewrite/ARR to redirect specific requests to the core application:
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="^api/(.*)" />
<action type="Rewrite" url="http://localhost:44444/{R:0}" logRewrittenUrl="false" />
</rule>
in this way, any request directed to /api/ will be forwarded (internally in IIS, not from the client) to another web application listening on port 44444
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0