由于在 abp.io 框架上工作,我收到 Http 错误 404
Posted
技术标签:
【中文标题】由于在 abp.io 框架上工作,我收到 Http 错误 404【英文标题】:I'm getting Http error 404 as a result on working on abp.io framework 【发布时间】:2021-03-03 22:42:10 【问题描述】:我是 abp.io 框架的新手,确切地说是 Angular + Entity Framework Core。
我希望能够创建或显示我已创建的类的对象列表。
例如,我在域层创建了一个名为 Address 的类。
这是它在应用层的AppService:
namespace ASKOM.RefPlusStudio.core.Services
[Authorize(corePermissions.Addresses.Default)]
public class AddressAppService : coreAppService, IAddressAppService
private readonly IAddressRepository _addressRepository;
private readonly AddressManager _addressManager;
public AddressAppService(IAddressRepository addressRepository, AddressManager addressManager)
_addressRepository = addressRepository;
_addressManager = addressManager;
[Authorize(corePermissions.Addresses.Create)]
public async Task<AddressDto> CreateAsync(CreateUpdateAddressDto input)
var address = await _addressManager.CreateAsync(
input.StreetNumber,
input.StreetName,
input.PostalCode,
input.City,
input.Country
);
await _addressRepository.InsertAsync(address);
return ObjectMapper.Map<Address, AddressDto>(address);
[Authorize(corePermissions.Addresses.Delete)]
public async Task DeleteAsync(Guid id)
await _addressRepository.DeleteAsync(id);
public async Task<AddressDto> GetAsync(Guid id)
var address = await _addressRepository.GetAsync(id);
return ObjectMapper.Map<Address, AddressDto>(address);
public async Task<PagedResultDto<AddressDto>> GetListAsync(GetAddressListDto input)
if (input.Sorting.IsNullOrWhiteSpace())
input.Sorting = nameof(Address.Country);
var addresses = await _addressRepository.GetListAsync(
input.SkipCount,
input.MaxResultCount,
input.Sorting,
input.Filter
);
var totalCount = await AsyncExecuter.CountAsync(
_addressRepository.WhereIf(
!input.Filter.IsNullOrWhiteSpace(),
address => address.Country.Contains(input.Filter)
)
);
return new PagedResultDto<AddressDto>(
totalCount,
ObjectMapper.Map<List<Address>, List<AddressDto>>(addresses)
);
[Authorize(corePermissions.Addresses.Edit)]
public async Task UpdateAsync(Guid id, CreateUpdateAddressDto input)
var address = await _addressRepository.GetAsync(id);
address.StreetNumber = input.StreetNumber;
address.StreetName = input.StreetName;
address.PostalCode = input.PostalCode;
address.City = input.City;
address.Country = input.Country;
await _addressRepository.UpdateAsync(address);
我给了他们所有需要的权限。
这里是 corePermissions.cs :
namespace ASKOM.RefPlusStudio.core.Permissions
public static class corePermissions
public const string GroupName = "core";
//Add your own permission names. Example:
//public const string MyPermission1 = GroupName + ".MyPermission1";
public static class Addresses
public const string Default = GroupName + ".Addresses";
public const string Create = Default + ".Create";
public const string Edit = Default + ".Edit";
public const string Delete = Default + ".Delete";
我想看看它是否可以显示地址列表,所以我在 DataSeeder 上制作了一个静态列表:
namespace ASKOM.RefPlusStudio.core
public class coreDataSeederContributor : IDataSeedContributor, ITransientDependency
private readonly IRepository<Address, Guid> _addressRepository;
private readonly IGuidGenerator _guidGenerator;
public coreDataSeederContributor(IRepository<Address, Guid> addressRepository, IGuidGenerator guidGenerator)
_addressRepository = addressRepository;
_guidGenerator = guidGenerator;
public async Task SeedAsync(DataSeedContext context)
if (await _addressRepository.GetCountAsync() > 0)
return;
var address = new Address(
id: _guidGenerator.Create(),
streetNumber: 07,
streetName: "Med Salah Belhaj",
postalCode: 2080,
city: "Ariana",
country: "Tunisie"
);
//autoSave: true
await _addressRepository.InsertAsync(address);
现在是 Swagger UI 上的结果:
当我尝试打开请求 URL 时,显示如下:
我确定我可能忘记了一些东西,这就是为什么我在请求 URL 上被拒绝访问,但我真的不知道它是什么,因为我是这方面的新手。
你能帮帮我吗? 谢谢
【问题讨论】:
让我们continue this discussion in chat. 【参考方案1】:数据库有问题。这就是它没有读取我在 DataSeedProvider 中提供的数据的原因。
【讨论】:
以上是关于由于在 abp.io 框架上工作,我收到 Http 错误 404的主要内容,如果未能解决你的问题,请参考以下文章