我正在将用 netcore2 编写的应用程序移植到 6,角度为 13。在 Visual Studio 中运行时,每个 Web api 控制器/方法总是收到 404 错误
[ApiController]
[Route("[controller]")]
public class GetOptionsController : Controller
{
private readonly GetOptionsService _getOptionsService;
public GetOptionsController(GetOptionsService getOptionsService)
{
_getOptionsService = getOptionsService;
}
[HttpGet]
public IActionResult GetOptions()
{
var options = _getOptionsService.GetOptions();
return Ok(options);
}
}
}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { IOption } from '../interfaces/option';
@Injectable()
export class OptionsService {
constructor(private http: HttpClient) { …Run Code Online (Sandbox Code Playgroud)