Khorshid
Khorshid

Reputation: 297

How to deploy two projects (Razor and Api) in Asp core

originally I make a web application (Razor Page Application) with Asp core 3.1 and it's work and been published to my host.

The client wants a mobile app, so I decide to build API. I know I can create the API in the same project or create new separate project (solution) for this purpose, but what is the best practice?

I saw a lot of developers make more than one project in solution (Model Project, Repository Project and the main project), so I create a new API project

new API project added to my solution

But now I don't know how to deploy and publish my second project I tried to publish it and then put it in separate sub-domain, but I get error: HTTP Error 500.0 - ASP.NET Core IIS hosting failure (in-process) // it not seem to be web config problem

My question is about best practice. Thanks

Upvotes: 1

Views: 748

Answers (1)

Fei Han
Fei Han

Reputation: 27803

You can try to host your ASP.NET Core API app as an IIS sub-application (sub-app) on same site that you used to host your Razor Page app.

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-5.0#sub-applications

And please note that we need to create and specify a separate app pool to the sub-app when using the in-process hosting model, otherwise the site would not work well.

Upvotes: 1

Related Questions