小编Dex*_*gan的帖子

CoreNet60 Angular 总是返回 404 错误

我正在将用 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)

c# .net-core asp.net-core angular webapi

2
推荐指数
1
解决办法
1166
查看次数

标签 统计

.net-core ×1

angular ×1

asp.net-core ×1

c# ×1

webapi ×1