我正在使用 VS Code 创建一个 asp.net 项目。这个问题首先被提出是因为我需要使用 AllowAnonymous 操作过滤器。它给出了“ The type or namespace name 'AllowAnonymousAttribute' could not be found.”的错误所以我添加了使用 System.Web.Mvc; 在开始部分。它显示error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web'你能给出任何建议吗?谢谢。using System;using System.Collections.Generic;using System.Linq;using System.Web.Mvc;using System.Threading.Tasks;using Microsoft.AspNetCore.Mvc;using DatingApp.API.Data;using Microsoft.EntityFrameworkCore;namespace DatingApp.API.Controllers{ [AllowAnonymous] [Route("api/[controller]")] public class ValuesController : Controller { private readonly DataContext _context; public ValuesController(DataContext context) { _context = context; } // GET api/values [HttpGet] public async Task<IActionResult> GetValues() { var values=await _context.Values.ToListAsync(); return Ok(values); }......运行后dotnet watch run,它给出了如下错误。watch : StartedControllers\ValuesController.cs(4,18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) [C:\Xumin\projects\DatingApp\DatingApp.API\DatingApp.API.csproj]Controllers\ValuesController.cs(12,6): error CS0246: The type or namespace name 'AllowAnonymousAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Xumin\projects\DatingApp\DatingApp.API\DatingApp.API.csproj]Controllers\ValuesController.cs(12,6): error CS0246: The type or namespace name 'AllowAnonymous' could not be found (are you missing a using directive or an assembly reference?) [C:\Xumin\projects\DatingApp\DatingApp.API\DatingApp.API.csproj]
2 回答
- 2 回答
- 0 关注
- 220 浏览
添加回答
举报
0/150
提交
取消