C
C#2y ago
oe

❔ Implement Angular in existing ASP.NET Core MVC project?

Hi, I have an ASP.NET MVC web app that takes a file upload in and produces an output. It uses Razor, HTML and some simple javascript in a <script> tag. I would like to recreate the project in Angular, React, Vue and lastly Blazor (instead of js) to test each framework out and see which one I like the best. I am currently trying to implement Angular, but I believe my web app uses server side rendering (SSR) as it uses ASP.NET Core MVC pattern.
My question is: how do I implement Angular in my existing ASP.NET MVC project ?
13 Replies
Angius
Angius2y ago
First and foremost, you'll need some API controllers Then make an Angular/Vue/React/Svelte/Qwik/Solid/Blazor app separately And have it connect to the API
oe
oeOP2y ago
Hi @Angius . I do have some API controllers In fact one of them takes a file upload and processes it, then outputs json data to the HTML using Razor I would like to implement Angular in this app preferably, instead of creating an API (seems hard to reimplement as an API?)
Angius
Angius2y ago
uh You need an API for Angular to be able to pull data from somewhere and to send data somewhere You can't really mix MVC SSR with frontend frameworks
oe
oeOP2y ago
Ok, I see Because the way I'm doing it right now is: @model IEnumerable<MyObject> Through razor Then I'm processing the data from the Model
Angius
Angius2y ago
Yeah, because you use SSR there
oe
oeOP2y ago
Ok. Cool, I get it
Angius
Angius2y ago
Angular/Vue/Whatever app can, however, be completely separate from the backend
oe
oeOP2y ago
And one last question...
Angius
Angius2y ago
The backend can be hosted on Digital Ocean, and the frontend on Cloudflare Pages or something
oe
oeOP2y ago
Is it straightforward to reimplement the file upload as a webapi instead of an MVC app? Currently am using an IFormFile as a parameter in the controller @Angius
Angius
Angius2y ago
Yeah You'll just need to send multipart/form-data type request instead of json
oe
oeOP2y ago
Ok Cool thank you man!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server