Hello, I just got started with using the dotnet-reactjs template on VS 2019. Can someone explain what these specific line of code do in the controller?
I probably won't need to use any of this boilerplate code, but still would be helpful if I'm writing this on my own.
Hello, I just got started with using the dotnet-reactjs template on VS 2019. Can someone explain what these specific line of code do in the controller?
Did you run your application and see the result displayed on your browser? You probably saw the followings:
Welcome to your new single-page application, built with:
ASP.NET Core and C# for cross-platform server-side code
React for client-side code
Bootstrap for layout and styling
The first one (i.e., ASP.NET Core and C# for cross-platform server-side code) is what you say "these specific line of code". It is a controller and action method of ASP.NET Core Web API.
Click the "Fetch data" link shown at upper right side on the browser. The result obtained from the ASP.NET Core Web API will be shown on the browser.
None
0 Points
1 Post
dotnet-reactjs template - explain code sample
Feb 08, 2021 03:05 PM|br14n|LINK
Hello, I just got started with using the dotnet-reactjs template on VS 2019. Can someone explain what these specific line of code do in the controller?
I probably won't need to use any of this boilerplate code, but still would be helpful if I'm writing this on my own.
Thanks!
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{ ... }
All-Star
53711 Points
24031 Posts
Re: dotnet-reactjs template - explain code sample
Feb 08, 2021 03:07 PM|mgebhard|LINK
The code is a Web API controller. You can learn about Web API from the official documentation.
https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-5.0&tabs=visual-studio
Member
390 Points
280 Posts
Re: dotnet-reactjs template - explain code sample
Feb 09, 2021 12:45 AM|SurferOnWww|LINK
Did you run your application and see the result displayed on your browser? You probably saw the followings:
Welcome to your new single-page application, built with:
The first one (i.e., ASP.NET Core and C# for cross-platform server-side code) is what you say "these specific line of code". It is a controller and action method of ASP.NET Core Web API.
Click the "Fetch data" link shown at upper right side on the browser. The result obtained from the ASP.NET Core Web API will be shown on the browser.