ABP-VNext 用户权限管理系统实战----问题与解决方案
1、swagger请求总是报:400 Bad Request,但是postman请求是没有问题
查看日志报表:
解决方案:
在 ConfigureServices 中增加如下的内容
Configure<AbpAntiForgeryOptions>(options => { //options.TokenCookie.Expiration = TimeSpan.Zero; options.AutoValidate = false; //表示不验证防伪令牌 });
2、请求接口报错:
System.MissingMethodException: Method not found: 'IdentityModel.Client.DiscoveryEndpoint IdentityModel.Client.DiscoveryEndpoint.ParseUrl(System.String)
解决方案:
JwtBearer配置修改,并升级 Microsoft.AspNetCore.Authentication.JwtBearer, Version=7.0.14.0
3、集成定时任务时报错:
Method not found: 'System.Type Microsoft.EntityFrameworkCore.Metadata.ITypeB
原因:之前定时任务的类库用的dll是支持6.0的,项目升级到了7.0后版本不兼容了。
解决方案:引用定时任务dll中的类与项目中的类EntityFrameworkCore版本不一致,升级到一致就可以了。
4、集成SignalR时报错
解决方案:
在使用的类库中将引用的版本改为:7.2.2
5、控制器服务注入服务层服务对像报错
Class:Volo.Abp.AspNetCore.Mvc.ExceptionHandling.AbpExceptionFilter
Message:An exception was thrown while activating Bridge.System.HttpApi.SysFileController -> Bridge.System.Application.SysFileService.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Bridge.System.HttpApi.SysFileController -> Bridge.System.Application.SysFileService.
---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'Bridge.System.Application.SysFileService' can be invoked with the available services and parameters:
Cannot resolve parameter 'Volo.Abp.Domain.Repositories.IRepository`2[Bridge.System.Domain.SysFile,System.Guid] sysFileRepository' of constructor 'Void .ctor(Volo.Abp.Domain.Repositories.IRepository`2[Bridge.System.Domain.SysFile,System.Guid], Microsoft.Extensions.Options.IOptions`1[Bridge.Shared.Models.SysOptions])'.
See https://autofac.rtfd.io/help/no-constructors-bindable for more info.
at Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass14_0.<UseSingleConstructorActivation>b__0(ResolveRequestContext context, Action`1 next)
解决方案:
检查SystemDbContext是否加了:public DbSet<SysFile> SysFiles { get; set; }
检查SystemDbContextModelCreatingExtensions是否加了:
builder.Entity<SysFile>(s =>
{
s.ToTable("t_sys_file");
s.ConfigureByConvention();
});
6、项目启动报错
解决方案:
注掉红框中的部分
7、home控制器中报错
解决方案:
加上HttpGet
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)