Venkat
Venkat

Reputation: 2186

Can we write the .net core WebAPI in the asp.net core razor web page itself?

I have the following projects in my solution all .net core 5.0.

 myproject.domain
 myproject.infrastructre
 myproject.webAPI
 myproject.UI.Razorweb page.

Instead of using SPA which calls the webAPI, I am using razor web page which will call the webAPI(.net 5.0). My question is can we merge the webAPI and the razorwebpage into one? Can we write webAPI in the razor web page itself?

Is that allowed?

Upvotes: 0

Views: 54

Answers (1)

Deepak-MSFT
Deepak-MSFT

Reputation: 11355

I agree with the suggestion given by Jeremy.

You should have a web API and Razor project separate.

Besides, if you would like to make some tests then you could refer to the articles below.

  1. Use Razor Pages, MVC, And Web API In A Single ASP.NET Core Application
  2. Hosting ASP.NET Core Razor Pages and Web APIs in a Single Project
  3. Razor pages and webapi in the same project

Upvotes: 1

Related Questions