Index.cshtml.cs 544 B

123456789101112131415161718192021222324
  1. using Dapr.Client;
  2. using Microsoft.AspNetCore.Mvc.RazorPages;
  3. namespace MyFrontEnd.Pages;
  4. public class IndexModel : PageModel
  5. {
  6. private readonly DaprClient _daprClient;
  7. public IndexModel(DaprClient daprClient)
  8. {
  9. _daprClient = daprClient;
  10. }
  11. public async Task OnGet()
  12. {
  13. var forecasts = await _daprClient.InvokeMethodAsync<IEnumerable<WeatherForecast>>(
  14. HttpMethod.Get,
  15. "MyBackEnd",
  16. "weatherforecast");
  17. ViewData["WeatherForecastData"] = forecasts;
  18. }
  19. }