前置条件
- 安装docker与dapr: 手把手教你学Dapr - 3. 使用Dapr运行第一个.Net程序
- 安装k8s
dapr 自托管模式运行
新建一个webapi无权限项目
launchSettings.json中applicationUrl端口改成5001,如下:
"applicationUrl": "http://localhost:5001"
//WeatherForecastController.cs更改如下
using Microsoft.AspNetCore.Mvc;
namespace backend.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast