M
M
MAdEagle2016-12-17 06:57:36
ASP.NET
MAdEagle, 2016-12-17 06:57:36

How to select news by id asp.net mvc?

Hello, I just started studying asp.net mvc not long ago and the following problem arises: I have a news block on the main page and when I click on a certain news url picks up the id and on another page I should display that news by id . on the news I go like this "/Home/News/@pic.Id" I'm interested in how to select news from the database by id

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2016-12-17
@evgshk

The data from a DB are selected by request.
Get the news Id with a GET request in the News method of the HomeController controller. Next, fetch data from the database with the condition of the existing Id.
Initialize your news model with the received data and pass the result to the news view.
https://www.asp.net/mvc/overview/getting-started/i...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question