vs2022 创建API 启动后SwaggerUI一片空白,且报错

昨天装机Win10系统,更换开发工具版本,新上VS2022,安装无问题,随后创建API,启动发现net6 在API这里自带Swagger,但看视频别人的都能成功,本机却不能,去掉swagger接口数据返回正常json,使用swagger就报错未找到。

img

I hope this is not too late to post. But I had the same issue and found a solution to it:

  1. Check if all your controller methods have [http] tag. If they all do and still doesn't work go to step 2
  2. In your configure function ensure that you have app.UseStaticFiles(); If it still doesn't work go to step 3
  3. Uninstall and reinstall swagger. If it doesn't work go to step 4 (Core Only)
  4. If you are using Core Install Microsoft.AspNetCore.StaticFiles and reference it in your project.
    That is as far as I got and mine started working
    题主参考下:
    https://github.com/DarkaOnLine/SwaggerLume/issues/33

    应该是资源路径加载有问题