How to properly set up view in MVC pattern?
Hello everyone, I'm studing MVC pattern in asp.net core. Could you help me how to set up view to my project?
1. I created libraries for model, repositories, and made crud/controllers in project call TNAI_FinalProject.Api as Web Api
2. Can I use this libraries to pass data on view?
3. If yes how to connect view (in visual studio for example) to these, to don't need to make over code.
4. If no, how should it looks.
5. What changes should I make in program.cs of TNAI.Web and TNAI.Api?
6. Could you describe me in example, how to code it?
I attached my project structure, and couple of code.
I guess it's really noob question, so plz don't judge lol.




25 Replies
I forgot to tell, TNAI.Web is a fresh project of asp.net core web app (model - view - controller) in visual studio.
Choose a framework of your choice and build the UI, which then communicates with the API
How to implement communication with this structure in razor page? Any correct reference?
Here is a repo. thats does what u are looking for: https://github.com/thbst16/dotnet-blazor-crud
GitHub
GitHub - thbst16/dotnet-blazor-crud: Modular application for databa...
Modular application for database CRUD with Blazor. Uses an in-memory database and features dummy data generation and data pagination. - thbst16/dotnet-blazor-crud
The server project in the repo is in this case ur api
Thanks dude 😎
U welcome
When I implement this, I will close the post and give a link to the repo If somebody is interested.
hey, i am interested in yoru project! pls send me the repo wehn you are done
this is blazor

they asked for razor pages, not components
The pages are in razor?
razor is what the template engine is called basicallt
razor pages mean static pages generated from a template
static as in without continuous interactivity
razor components have to do with blazor
Ah i see my bad
Wait wait I was looking for an implementation of get pass data from server on UI, I guess it doesn't matter this is blazor or razor pages. Change my mind if I'm wrong
I'm going ahead right now, so I will check it
what does that mean?
"get pass data from server on UI"
It means you are "taking" informations from server, to see these on view
what does "taking" mean?
for example

continuously listening on events?
polling for updates?
one-time request-response?
this is templating
and this?

In principle, templating doesn't have to do with servers or the client
that's a controller
but is this getting data from server?
thing that exposes http endpoints of the server to the clients
no, it's not, it's on the server exclusively
it doesn't run on the client
the client makes requests to the server and gets back data that you return in your endpoints
the client makes an http request