1

In Webforms you could use an ObjectDataSource, use methods defined in your Business Logic Layer that would get data from your Data Layer, usually a data set or EF. Then all the code accessing database would be all in one place and retrieved logically based on methods.

In .Net Core Razor, how do you organize this?

1
  • 2
    Generally speaking, you just throw it all in a class library. Much more than that I can't say as you haven't provided much information about what you're trying to do. Commented Mar 21, 2019 at 18:22

1 Answer 1

1

.NET Core web apps generally follows the Model View Controller (MVC) pattern, but you can use 'Razor Pages' for simpler apps.

If you're using MVC then in your razor views you should just be displaying data in the model for the view. A model is typically a simple Plain Old C# Object (POCO).

The model is created and populated in the controller from any data source or service.

If you're new to MVC from web forms then this guide on .NET Core MVC should be helpful.

If your app is pretty simple then this guide on Razor Pages might be helpful.

Sign up to request clarification or add additional context in comments.

1 Comment

I see, i don't know much about MVC yet but i have started using controllers on a razor pages template, basically just mixing stuff around when it's suitable. So I have a controller for my Car model, GetCars Action will just do the db call and populate it. Looks clean and simple

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.