jasontaylordev / cleanarchitecture Goto Github PK
View Code? Open in Web Editor NEWClean Architecture Solution Template for ASP.NET Core
License: MIT License
Clean Architecture Solution Template for ASP.NET Core
License: MIT License
Commands and queries can be Value Objects.
Wondering how to implement application logic that reference to ApplicationUser. F.e how to show only TodoLists that belongs to the current user. Where this logic should go?
How to customize ApplicationUser in right way. F.e if i have Image entity in my domain, how i can associate this image with ApplicationUser( as i understand i can't use shadow properties as AppUser is not part of the domain)
Hi,
Can I use the VS Code with this template? i.e. I would like to have 2 folders on VS code as one for Web API and Other for the Angular 8 project. Is this possible?
Hi Jason,
I watched your presentation about C.A. on Youtube. I think is cleaner if you separate command and command handlers in two classes. The command responsability is only to carry data (simple DTO) and command handler is responsible to process command.
Describe the bug
Following the installation instructions when using a Mac does not result in installation of Nuget package.
To Reproduce
Steps to reproduce the behavior:
dyld: lazy symbol binding failed: Symbol not found: _utimensat
Referenced from: /usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.1/System.Native.dylib
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _utimensat
Referenced from: /usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.1/System.Native.dylib
Expected in: /usr/lib/libSystem.B.dylib
Expected behavior
Running installation on Mac should result in same behaviour as a PC and running the instruction should cause cs-sln template to be available to create a new VS solution with.
If the template does not work on a Mac, this should be clear and explicit on the GitHub readme.md.
Additional context
I am not generally a Mac user but it was first to hand when I wanted to try out Clean Architecture after watching presentation at NDC Sydney.
Thank you for your project!
I have a REST service that I'm connecting to. The service is at Infrastructure level.
But, where do I process errors of answers from REST?
As I understand it, I can't return HttpResponse to the App level because it's leaking. It's just important for the App to know if the request was successful or not.
As I see it.
try .. catch inside Application layer for a certain error.
or, make the Result class {T Data, string Error }.
In general, perhaps two approaches have their pros and cons. But which one is more in line with the philosophy
Describe the bug
The name of the folder where solution template is installed is substituted into an issue link in readme.md
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Issue link is hardcoded
Hi,
Thanks for the really great project/template! I'm not sure if this is the right place to ask, but is there a way to use MySQL as DB?
I have tried installing Pomelo.EntityFrameworkCore.MySql and shifting the "UseSqlServer" to "UseMySql", but it fails with migrations.
Best,
Itaakara 'Itaanikus'
I am still new to Identity Server, still reading and exploring. I saw that there are roles that can be used to classify users. I don't know how to start that within this template and how to derive from my users in my domain.
My request is to include roles in the template.
How to use them to restrict access to certain controllers or certain methods in a controller if possible.
Show navigation items based on the user role. An example would be only an admin can register a user in the system, i.e issue login and password. While a user can only access items that does not include managerial duties.
Cheers
I try to build and run the default project created from https://github.com/JasonGT/CleanArchitecture in .NET Core 3.1.100 in Ubuntu.
(1) It has a project for each layer. However, it doesn't ask me to explicitly build the other projects than the webUI project, according to these two steps:
dotnet new ca-sln
to create a new projectdotnet run
to launch the projectIs it true that when a project is being built, are all its dependency projects automatically built?
(2) When I run it as described above, and connect to https://localhost:5001/ from web browser
{"error":"One or more errors occurred. (One or more errors occurred. (Failed to start 'npm'. To resolve this:.\n\n[1] Ensure that 'npm' is installed and can be found in one of the PATH directories.\n Current PATH enviroment variable is: /home/t/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/t/.dotnet/tools:/opt/mssql-tools/bin\n Make sure the executable is in one of those directories, or update your PATH.\n\n[2] See the InnerException for further details of the cause.))"}
My npm is installed in /usr/bin/npm
, which is in my PATH
. I can start npm from shell without problem. So why do I have the problem that npm is not resolved and how could I solve the problem?
Thanks.
Hi Jason,
What's the best way to implement CleanArchitecture for multi-microservices with an API Gateway?
Do you have any suggestion?
Regards,
Derek Hu
Describe the bug
The Common folder is inside of the ClientApp folder.
To Reproduce
Look at the structure.
Expected behavior
Shouldn't this one be in the root of the WebUI project?
Screenshots
-
Additional context
-
Hello, after reading some comments on your latest Youtube videos I read a little bit more about DDD models. It looks like you have been trying to implement some parts with ValueObject for example but not the full thing with aggregate, etc.
What is your opinion on all of this?
I was reading more about it here.
I am new to CA and found this repo extremely helpful in learning so this is more of a question than a feature request.
I noticed that in the Application layer (project) you define a DBContext interface (IApplicationDbContext) which requires you to add EF Core dependency to the Application project.
It seems to me that EF Core is an infrastructure concern, so I'm wondering why you did it this way vs, say, defining a Repository or Service interface and have the implementation in the infrastructure project.
Thank you Jason and the community for the brilliant work on this solution. I just finished watching your latest NDC talk and I think it's brilliant.
I was wondering whether anyone is forking this to make a version with React as the front-end? I will try and give it a go but I am really new to it.
H.
In https://github.com/JasonGT/CleanArchitecture, Startup.ConfigureServices()
in src/WebUI/Startup.cs
registers services for dependency injection.
AddInfrastructure()
in src/Infrastructure/DependencyInjection.cs
also registers services. But is it correct that class DependencyInjection
and method AddInfrastructure()
are not used in any other files? What are their purposes?
Putting services.AddContextDb()
in DependencyInjection.AddInfrastructure()
may have caused definition of 'UseSqlite' not found in #52
Thanks.
Hi Jason,
Thank you for this great project. I really like your concept of having the developer fall in a "pit of success".
I've been trying to use dotnet ef
to add migrations but I get an error saying that the ApplicationDbContext cannot be created.
Is there a preferred/recommended way of doing this in this template?
Hello,
In the interface IMapFrom, there is a default implementation for the Mapping method
public interface IMapFrom<T>
{
void Mapping(Profile profile) => profile.CreateMap(typeof(T), GetType());
}
If I have a Class PersonVM which implements IMapFrom like this
public class PersonVM : IMapFrom<Domain.Person>
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public int Age { get; set; }
}
It will throw an exception at runtime : "The mapping between PersonVM and Domain.Person is not found."
It will work If I implement the interface IMapFrom like this :
public class PersonVM : IMapFrom<Domain.Person>
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public int Age { get; set; }
public void Mapping(Profile profile)
{
profile.CreateMap<Domain.Person, PersonVM>();
}
}
Am I missing something? I don't want to implement a method Mapping() every time..
Thank you so much.
Hey Jason, I just wanted to know what the differences are in these 2 projects.
I would like to try the default project created from the template on Ubuntu 18.04. I have installed SQL Server mssql-server_15.0.4003.23-3_amd64.deb
and choose Express as edition. Since LocalDB is Windows only, I figure that I have to modify src/WebUI/appsettings.json
to replace LocalDB connection string with the following SQL Server connection string (I am not sure if it is correct):
"ConnectionStrings": {
"DefaultConnection": "Server=localhost\\SQLEXPRESS,1433;Database=ExampleDb;User Id=sa;Password=password;"
},
Then I go into src/WebUI/
and build it but fail (see below). The errors seem not related to my change of the connection string.
Regarding the first error, I open src/Domain/Domain.csproj
in Emacs, which shows something strange <U+FEFF>
, which https://en.wikipedia.org/wiki/Byte_order_mark says is about endianness. I wonder how I could make the files work?
<U+FEFF>namespace default.Domain.Enums
{
public enum PriorityLevel
{
None,
Low,
Medium,
High
}
}
Thanks.
$ dotnet build
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 147.56 ms for /tmp/test/default/src/Domain/Domain.csproj.
Restore completed in 213.91 ms for /tmp/test/default/src/Application/Application.csproj.
Restore completed in 57.04 ms for /tmp/test/default/src/Infrastructure/Infrastructure.csproj.
Restore completed in 9.65 ms for /tmp/test/default/src/WebUI/WebUI.csproj.
Enums/PriorityLevel.cs(1,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(2,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(4,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,32): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(7,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,27): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(6,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(4,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Build FAILED.
Enums/PriorityLevel.cs(1,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(1,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Enums/PriorityLevel.cs(2,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(3,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Exceptions/AdAccountInvalidException.cs(4,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(2,32): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(6,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
ValueObjects/AdAccount.cs(7,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(4,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/ValueObject.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(2,27): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(5,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoItem.cs(6,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1002: ; expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,22): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,7): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(1,28): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(4,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Entities/TodoList.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,11): error CS1001: Identifier expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,26): error CS0116: A namespace cannot directly contain members such as fields or methods [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,11): error CS1514: { expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(3,18): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
Common/AuditableEntity.cs(4,1): error CS1022: Type or namespace definition, or end-of-file expected [/tmp/test/default/src/Domain/Domain.csproj]
0 Warning(s)
60 Error(s)
Describe the bug
I've noticed in the Infrastructure.csproj file that it is targetting netcoreapp3.1
yet the SDK is the normal one (not the web sdk).
Why is this?
I thought the netcoreapp
should be the project which contains the HOST (e.g the WebUI / WebApi project).
I'm wondering if this is a bug and it should be targetting netstandard20
instead.
I am encountering a strange compilation message when trying to start the project as described in the Getting Started section of the readme.
To Reproduce
Expected behavior
Project starts up without errors.
Additional context
info: Microsoft.AspNetCore.SpaServices[0]
i โฉโรณwdmโฉโรบ: Compiled successfully.
Issue
I would like to really understand how to add some of the classic things explained in the Microsoft Documentation (like social login) but with the SPA application. I am going to try but myself but I would love to see your solution for this.
For example the solution described here
Once again, I am going to try and implement this by myself. I would like users to be able to authenticate with an account, or Facebook/Google/Twitter, to be able to link those accounts together as their accounts and to have different roles in the application. I need to fill the gap between your implementation that I love for its simplicity to these features that are necessary for me.
Quick question, is there an easy way to extend this model to add some extra user data like date of birth, etc.?
Thanks again for all your work on this and Northwind Traders it is really appreciated.
Hi Jason,
first of all: great template, thanks for all the hard work put into this repository!
Following the clean architecture approach, can you either describe or provide a sample implementation of overriding the default identity pages? It would be trivial to scaffold any given identity page, such as login, logout, pw reset, etc. via Visual Studio. But this would generate MVC based razor pages and I wonder if there was an approach using the Angular 8 frontend within your clean architecture eco system that you'd recommend.
Thank you very much in advance!
I understand mapping from Domain Models to DTOs/Vms can be done using IMapFrom<>, but in case of updating a domain entity we will not be able to use IMapFrom<> as that would mean Domain layer would need to reference the Application layer and that is not recommended.
So as far as I see for now the 2 options available are to either,
If we go with the 2nd option then the mapping configurations would be in DTOs and also in other mapping configuration files which feels a bit weird. Or do you recommend always going with option 1 no matter how many fields a DTO/Vm has (can get messy if handling lists and complex objects).
What would be the better practice or an alternative solution to solve this?
Is your feature request related to a problem? Please describe.
A 400 response from /api/TodoList/{id} looks like:
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "Bad Request",
"status": 400,
"traceId": "|e46a85a0-4b31bf31a62d8f20."
}
A 404 response from /api/TodoList/{id} looks like:
{
"error": "Entity \"TodoList\" (45) was not found."
}
In order to write global error handling on the client side I would have to write costum checks for all possible responses.
Describe the solution you'd like
What would make error handling on the client side very easy would be if all erros where formated something like:
{
"success": "false",
"error": "404",
"message": Entity \"TodoList\" (45) was not found."
}
Describe alternatives you've considered
Current alternative is to write custom handling for errors that does not give the response:
{
"error": "Entity \"TodoList\" (45) was not found."
}
Additional context
I have none.
I am having error (Unable to create an object of type 'ApplicationDbContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728) when running "dotnet ef migrations add sampleMigation" inside the infrastructure project. Am I doing the right way?
Kindly advise.
Thanks!
It is not a bug, but a question.
Why do you use view models for returning result from queries ?
For example, GetTodoItemQuery returns TodoItemVm, however it looks like DTO mroe than VM.
As I know, by DDD we should return DTOs from application layer.
Describe the bug
after installing Visual studio 16.4. the command
dotnet new ca-sln will not work.
I reinstalled the template and was able to create a new project however the resulted solution is different it looks like it rolled back to 2.2 template, specifically in the Application folder.
The query and the handler are in a separate files and it does not use ProjectTo in LINQ.
I try to build and run the default project created from https://github.com/JasonGT/CleanArchitecture in .NET Core 3.1.100 in Ubuntu, though my questions are not specific to Ubuntu. It uses LocalDB and SQL Server, and I try to replace them with other database systems, e.g. SQLite (it can also be InMemory provided by EF, PostgreSQL, MySQL), by making the following changes:
(1) I found the following file containing "LocalDB": src/WebUI/appsettings.json
, so I replace its LocalDB connection string with "DefaultConnection": "Data Source=Example.db"
in the file.
(2) I found the following file containing "sqlserver": src/Infrastructure/DependencyInjection.cs
, so I replace options.UseSqlServer()
with options.UseSqlite()
in the file.
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration, IWebHostEnvironment environment)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite( // options.UseSqlServer(
configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly(typeof(ApplicationDbContext).Assembly.FullName)));
(3) I then add dotnet add package Microsoft.EntityFrameworkCore.Sqlite
and dotnet add package Microsoft.EntityFrameworkCore.Design
to src/WebUI/WebUI.csproj
. There seems to be some version mismatching problem between the dependency packages. I figure that I either need to downgrade the EF Sqlite package version from 3.1.1 to 3.1.0, or upgrade the other packages' versions from 3.1.0 to 3.1.1 except build error telling that Microsoft.VisualStudio.Web.CodeGeneration.Design
should remain at 3.1.0
(4) After either downgrade SQlite package or upgrade the other packages, I got build error
src/Infrastructure/DependencyInjection.cs(26,11): error CS1061: 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlite' and no accessible extension method 'UseSqlite' accepting a first argument of type 'DbContextOptionsBuilder' could be found (are you missing a using directive or an assembly reference?)".
Some link says they added Sqlite.Design package, but when I run dotnet add package Entity.Framework.Core.Sqlite.Design
I got error:
Package 'Entity.Framework.Core.Sqlite.Design' is incompatible with 'all' frameworks in project".
My questions are:
Thanks.
I have a DeleteDailyCommand
and sending it via MediatR from an app-internal Quartz scheduler. But all pipeline behaviours relying on the http context fail, as its not available during the internal send. How would you call system internal commands or bring them into this architecture?
Hello,
I would like to use Quartz.NET. Where should I define my jobs? And how to schedule jobs?
Thanks
Hey!
Could anyone tell me why SignInManager.IsSignedIn(User) == false here, when accessing the root page, and is working ok when accessing the Login or Register pages?
Hello ..
I have a problem.
When I perform any operation(Update,Insert ,Read), this error is shown (Enumerator failed to MoveNextAsync).
I did not understand what it means.
I could not add any record to the database.
Thank you.
Is your feature request related to a problem? Please describe.
Enable multiple API versions and the way to display those in the swagger UI.
Is your feature request related to a problem? Please describe.
The content negotiation used when (de)serializing objects is not respected and errors are always formatted in JSON.
Describe the solution you'd like
An implementetation which respects the content wanted by the client. Also what do you think about the StatusCodes.*
constants as an alternative to (int) HttpStatusCode.*
?
Describe alternatives you've considered
-
Additional context
My current implementation (slightly changed yours and maybe improvable):
public class CustomExceptionHandlerMiddleware
{
private readonly RequestDelegate _next;
private readonly ILogger _logger;
public CustomExceptionHandlerMiddleware(RequestDelegate next, ILogger<CustomExceptionHandlerMiddleware> logger)
{
_next = next;
_logger = logger;
}
public async Task Invoke(HttpContext context)
{
try
{
await _next(context);
}
catch (Exception ex)
{
await HandleExceptionAsync(context, ex);
}
}
private Task HandleExceptionAsync(HttpContext context, Exception exception)
{
_logger.LogError(exception, $"An unhandled exception has occurred. Url: {context.Request.GetDisplayUrl()}");
if (context.Response.HasStarted)
{
// We have no other choice as we can't modify the response anymore
throw exception;
}
var error = new ErrorResponse()
{
Message = "An error occured."
};
ProcessException(exception, error, out var code);
context.Response.StatusCode = code;
context.Response.ContentType = "application/json";
return context.Response.WriteAsync(JsonConvert.SerializeObject(error));
}
private void ProcessException(Exception exception, ErrorResponse response, out int statusCode)
{
statusCode = StatusCodes.Status500InternalServerError;
switch (exception)
{
case ValidationException validationException:
statusCode = StatusCodes.Status400BadRequest;
response.Message = "The data you sent is not valid.";
response.Error = validationException.Failures;
break;
case NotFoundException _:
statusCode = StatusCodes.Status404NotFound;
break;
}
}
}
public static class CustomExceptionHandlerMiddlewareExtensions
{
public static IApplicationBuilder UseCustomExceptionHandler(this IApplicationBuilder builder)
{
return builder.UseMiddleware<CustomExceptionHandlerMiddleware>();
}
}
I already implemented some kind of a solution in an earlier AspNetCore version where "everything" was processed by MVC. Don't know if it's still able to do what it is expected to do:
ErrorResponse.cs
(also used above)
public class ErrorResponse
{
public string Message { get; set; }
mpublic object Error { get; set; }
}
ErrorHandlingMiddleware.cs
public class ExceptionHandlingMiddleware
{
private readonly ILogger logger;
private readonly RequestDelegate next;
private readonly IActionResultExecutor<ObjectResult> executor;
private static readonly ActionDescriptor EmptyActionDescriptor = new ActionDescriptor();
public ExceptionHandlingMiddleware(RequestDelegate next, IActionResultExecutor<ObjectResult> executor, ILoggerFactory loggerFactory)
{
this.next = next;
this.executor = executor;
this.logger = loggerFactory.CreateLogger<ExceptionHandlingMiddleware>();
}
public async Task Invoke(HttpContext context)
{
try
{
await this.next(context);
}
catch (Exception ex)
{
await HandleExceptionAsync(context, ex);
}
}
private async Task HandleExceptionAsync(HttpContext context, Exception exception)
{
HttpStatusCodeException unifiedException;
if (!(exception is HttpStatusCodeException))
{
this.logger.LogError(exception, $"An unhandled exception has occurred while executing the request. Url: {context.Request.GetDisplayUrl()}");
unifiedException = new HttpStatusCodeException("Error processing request. Please contact your administrator.", StatusCodes.Status500InternalServerError);
}
else
{
unifiedException = exception as HttpStatusCodeException;
}
if (context.Response.HasStarted)
{
throw exception;
}
var routeData = context.GetRouteData() ?? new RouteData();
var actionContext = new ActionContext(context, routeData, EmptyActionDescriptor);
var result = new ObjectResult(new ErrorResponse(unifiedException.Message, unifiedException.Error))
{
StatusCode = unifiedException.StatusCode
};
await this.executor.ExecuteAsync(actionContext, result);
}
}
HttpStatusCodeException.cs
(NotFoundException and so on inherit from this one and fill some defaults)
public class HttpStatusCodeException : Exception
{
public HttpStatusCodeException() : base()
{
this.StatusCode = StatusCodes.Status500InternalServerError;
}
public HttpStatusCodeException(int statusCode) : base()
{
this.StatusCode = statusCode;
}
public HttpStatusCodeException(string message, int statusCode) : base(message)
{
this.StatusCode = statusCode;
}
public HttpStatusCodeException(string message) : base(message)
{
}
public HttpStatusCodeException(string message, Exception innerException) : base(message, innerException)
{
}
public int StatusCode { get; set; }
public object Error { get; set; }
}
Describe the bug
I followed the steps, added the template and created a new project. And use dotnet run
. Browser can open the page. However, it got the following error in the javascript console and login doesn't work.
zone-evergreen.js:1042 GET http://localhost:58600/_configuration/padmatch.WebUI 404 (Not Found)
(anonymous) @ zone-evergreen.js:1042
(anonymous) @ authorize.service.ts:177
(anonymous) @ authorize.interceptor.ts:10
ZoneAwarePromise @ zone-evergreen.js:876
push../src/api-authorization/authorize.service.ts.__awaiter @ authorize.interceptor.ts:10
ensureUserManagerInitialized @ authorize.service.ts:172
getUserFromStorage @ authorize.service.ts:194
getUser @ authorize.service.ts:54
isAuthenticated @ authorize.service.ts:48
ngOnInit @ login-menu.component.ts:18
checkAndUpdateDirectiveInline @ core.js:24489
checkAndUpdateNodeInline @ core.js:35151
checkAndUpdateNode @ core.js:35090
debugCheckAndUpdateNode @ core.js:36112
debugCheckDirectivesFn @ core.js:36055
eval @ NavMenuComponent.html:10
debugUpdateDirectives @ core.js:36043
checkAndUpdateView @ core.js:35055
callViewAction @ core.js:35421
execComponentViewsAction @ core.js:35349
checkAndUpdateView @ core.js:35062
callViewAction @ core.js:35421
execComponentViewsAction @ core.js:35349
checkAndUpdateView @ core.js:35062
callWithDebugContext @ core.js:36395
debugCheckAndUpdateView @ core.js:35978
detectChanges @ core.js:23793
tick @ core.js:32067
_loadComponent @ core.js:32118
bootstrap @ core.js:32041
(anonymous) @ core.js:31663
_moduleDoBootstrap @ core.js:31659
(anonymous) @ core.js:31614
invoke @ zone-evergreen.js:359
onInvoke @ core.js:30892
invoke @ zone-evergreen.js:358
run @ zone-evergreen.js:124
(anonymous) @ zone-evergreen.js:855
invokeTask @ zone-evergreen.js:391
onInvokeTask @ core.js:30873
invokeTask @ zone-evergreen.js:390
runTask @ zone-evergreen.js:168
drainMicroTaskQueue @ zone-evergreen.js:559
Promise.then (async)
scheduleMicroTask @ zone-evergreen.js:542
scheduleTask @ zone-evergreen.js:381
scheduleTask @ zone-evergreen.js:211
scheduleMicroTask @ zone-evergreen.js:231
scheduleResolveOrReject @ zone-evergreen.js:845
then @ zone-evergreen.js:955
bootstrapModule @ core.js:31644
./src/main.ts @ main.ts:19
webpack_require @ bootstrap:78
0 @ main.ts:20
webpack_require @ bootstrap:78
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1
Show 13 more frames
zone-evergreen.js:1042 GET http://localhost:58600/_configuration/padmatch.WebUI 404 (Not Found)
(anonymous) @ zone-evergreen.js:1042
(anonymous) @ authorize.service.ts:177
(anonymous) @ authorize.interceptor.ts:10
ZoneAwarePromise @ zone-evergreen.js:876
push../src/api-authorization/authorize.service.ts.__awaiter @ authorize.interceptor.ts:10
ensureUserManagerInitialized @ authorize.service.ts:172
getUserFromStorage @ authorize.service.ts:194
getUser @ authorize.service.ts:54
ngOnInit @ login-menu.component.ts:19
checkAndUpdateDirectiveInline @ core.js:24489
checkAndUpdateNodeInline @ core.js:35151
checkAndUpdateNode @ core.js:35090
debugCheckAndUpdateNode @ core.js:36112
debugCheckDirectivesFn @ core.js:36055
eval @ NavMenuComponent.html:10
debugUpdateDirectives @ core.js:36043
checkAndUpdateView @ core.js:35055
callViewAction @ core.js:35421
execComponentViewsAction @ core.js:35349
checkAndUpdateView @ core.js:35062
callViewAction @ core.js:35421
execComponentViewsAction @ core.js:35349
checkAndUpdateView @ core.js:35062
callWithDebugContext @ core.js:36395
debugCheckAndUpdateView @ core.js:35978
detectChanges @ core.js:23793
tick @ core.js:32067
_loadComponent @ core.js:32118
bootstrap @ core.js:32041
(anonymous) @ core.js:31663
_moduleDoBootstrap @ core.js:31659
(anonymous) @ core.js:31614
invoke @ zone-evergreen.js:359
onInvoke @ core.js:30892
invoke @ zone-evergreen.js:358
run @ zone-evergreen.js:124
(anonymous) @ zone-evergreen.js:855
invokeTask @ zone-evergreen.js:391
onInvokeTask @ core.js:30873
invokeTask @ zone-evergreen.js:390
runTask @ zone-evergreen.js:168
drainMicroTaskQueue @ zone-evergreen.js:559
Promise.then (async)
scheduleMicroTask @ zone-evergreen.js:542
scheduleTask @ zone-evergreen.js:381
scheduleTask @ zone-evergreen.js:211
scheduleMicroTask @ zone-evergreen.js:231
scheduleResolveOrReject @ zone-evergreen.js:845
then @ zone-evergreen.js:955
bootstrapModule @ core.js:31644
./src/main.ts @ main.ts:19
webpack_require @ bootstrap:78
0 @ main.ts:20
webpack_require @ bootstrap:78
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1
Show 12 more frames
core.js:7187 ERROR Error: Uncaught (in promise): Error: Could not load settings for 'padmatch.WebUI'
Error: Could not load settings for 'padmatch.WebUI'
at AuthorizeService. (authorize.service.ts:179)
at Generator.next ()
at fulfilled (authorize.interceptor.ts:10)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:30892)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:30873)
at resolvePromise (zone-evergreen.js:797)
at zone-evergreen.js:707
at fulfilled (authorize.interceptor.ts:10)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:30892)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:30873)
defaultErrorLogger @ core.js:7187
handleError @ core.js:7239
next @ core.js:31602
schedulerFn @ core.js:27834
__tryOrUnsub @ Subscriber.js:183
next @ Subscriber.js:122
_next @ Subscriber.js:72
next @ Subscriber.js:49
next @ Subject.js:39
emit @ core.js:27796
(anonymous) @ core.js:30931
invoke @ zone-evergreen.js:359
run @ zone-evergreen.js:124
runOutsideAngular @ core.js:30818
onHandleError @ core.js:30928
handleError @ zone-evergreen.js:363
runGuarded @ zone-evergreen.js:137
api.microtaskDrainDone @ zone-evergreen.js:663
drainMicroTaskQueue @ zone-evergreen.js:566
Promise.then (async)
scheduleMicroTask @ zone-evergreen.js:542
scheduleTask @ zone-evergreen.js:381
onScheduleTask @ zone-evergreen.js:272
scheduleTask @ zone-evergreen.js:372
scheduleTask @ zone-evergreen.js:211
scheduleMicroTask @ zone-evergreen.js:231
scheduleResolveOrReject @ zone-evergreen.js:845
resolvePromise @ zone-evergreen.js:791
(anonymous) @ zone-evergreen.js:707
Promise.then (async)
(anonymous) @ zone-evergreen.js:1033
ZoneAwarePromise @ zone-evergreen.js:876
Ctor.then @ zone-evergreen.js:1032
resolvePromise @ zone-evergreen.js:758
(anonymous) @ zone-evergreen.js:707
(anonymous) @ authorize.interceptor.ts:10
ZoneAwarePromise @ zone-evergreen.js:876
step @ authorize.interceptor.ts:10
(anonymous) @ authorize.interceptor.ts:10
ZoneAwarePromise @ zone-evergreen.js:876
push../src/api-authorization/authorize.service.ts.__awaiter @ authorize.interceptor.ts:10
ensureUserManagerInitialized @ authorize.service.ts:172
getUserFromStorage @ authorize.service.ts:194
getUser @ authorize.service.ts:54
ngOnInit @ login-menu.component.ts:19
checkAndUpdateDirectiveInline @ core.js:24489
checkAndUpdateNodeInline @ core.js:35151
checkAndUpdateNode @ core.js:35090
debugCheckAndUpdateNode @ core.js:36112
debugCheckDirectivesFn @ core.js:36055
eval @ NavMenuComponent.html:10
debugUpdateDirectives @ core.js:36043
checkAndUpdateView @ core.js:35055
callViewAction @ core.js:35421
execComponentViewsAction @ core.js:35349
checkAndUpdateView @ core.js:35062
callViewAction @ core.js:35421
execComponentViewsAction @ core.js:35349
checkAndUpdateView @ core.js:35062
callWithDebugContext @ core.js:36395
debugCheckAndUpdateView @ core.js:35978
detectChanges @ core.js:23793
tick @ core.js:32067
_loadComponent @ core.js:32118
bootstrap @ core.js:32041
(anonymous) @ core.js:31663
_moduleDoBootstrap @ core.js:31659
(anonymous) @ core.js:31614
invoke @ zone-evergreen.js:359
onInvoke @ core.js:30892
invoke @ zone-evergreen.js:358
run @ zone-evergreen.js:124
(anonymous) @ zone-evergreen.js:855
invokeTask @ zone-evergreen.js:391
onInvokeTask @ core.js:30873
invokeTask @ zone-evergreen.js:390
runTask @ zone-evergreen.js:168
drainMicroTaskQueue @ zone-evergreen.js:559
Promise.then (async)
scheduleMicroTask @ zone-evergreen.js:542
scheduleTask @ zone-evergreen.js:381
scheduleTask @ zone-evergreen.js:211
scheduleMicroTask @ zone-evergreen.js:231
scheduleResolveOrReject @ zone-evergreen.js:845
then @ zone-evergreen.js:955
bootstrapModule @ core.js:31644
./src/main.ts @ main.ts:19
webpack_require @ bootstrap:78
0 @ main.ts:20
webpack_require @ bootstrap:78
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1
Show 46 more frames
2core.js:7187 ERROR Error: Could not load settings for 'padmatch.WebUI'
at AuthorizeService. (authorize.service.ts:179)
at Generator.next ()
at fulfilled (authorize.interceptor.ts:10)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:30892)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:30873)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The login page shows the boxes
Additional context
However, open the .sln file using visual studio 2019, there is no javascript console error and the login page works. (Both run as IIS Express or kestrel)
How to create jwt token
Hi, feature request because I did not know.
1 - How do i proceed to generate jwt token.
2 - How do i add claims information.
can you help me.
thanks.
Add feature to select options for UI Application.
I see that you have AdAccount as a ValueObject but that it is not used anywhere else than in the tests. Would it be possible to have Active Directory Login with Azure enabled for this application even if the Classic Application Login is already enabled?
I suppose this is already in your plans since you have this class in there I just wanted to make sure. Once again, if I am able to come up to a clean solution myself I'll try to add to the project if that's interesting.
Thank you,
The fact that this application is using Identity with a JWT is hidden coupling within the Infrastructure project, so this project implicitly knows that it is a .net core web application already.
I feel like there is a disconnect here: either the web specific infrastructure should be in the web project, or the current user service should be in the infrastructure project.
Currently I am trying to support multiple databases based on incoming CORS request api keys (what I have is working); the general gist is:
in CleanArchitecture.Infrastructure.DependencyInjection:
var appSettingsSection = Configuration.GetSection("AppSettings");
services.Configure<AppSettings>(appSettingsSection);
var appSettings = appSettingsSection.Get<AppSettings>();
services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
policy
.WithOrigins(appSettings.Keys.Select(k => k.Value.Origin).Distinct().ToArray())
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials()
.WithExposedHeaders("authorization")
);
});
services.AddDbContext<ApplicationDbContext>((serviceProvider, builder) =>
{
var connectionString = serviceProvider.GetRequiredService<IConnectionStringService>().ConnectionString;
builder.UseSqlServer(connectionString,
b => b.MigrationsAssembly(typeof(ApplicationDbContext).Assembly.FullName));
});
// ...
and IConnectionStringService has an infrastructure implementation (calling some legacy code to return a connection string based on client id) which in turn depends on an IClientService implementation which the web application would provide as:
public class ClientService : IClientService
{
public ClientAccessService(IHttpContextAccessor httpContextAccessor, IOptions<AppSettings> appSettings)
{
if (httpContextAccessor == null) throw new ArgumentNullException(nameof(httpContextAccessor));
if (appSettings == null) throw new ArgumentNullException(nameof(appSettings));
Client = GetClient(httpContextAccessor, appSettings);
}
public string? Client { get; }
private string? GetClient(IHttpContextAccessor httpContextAccessor, IOptions<AppSettings> appSettings)
{
var context = httpContextAccessor.HttpContext;
if (context == null) return null;
var key = context.Request.Headers["x-api-key"];
var origin = context.Request.Headers["origin"];
if (!string.IsNullOrEmpty(key) && appSettings.Value.Keys.TryGetValue(key, out var value))
{
if (string.IsNullOrEmpty(value.Origin) || string.Equals(value.Origin, origin, StringComparison.OrdinalIgnoreCase))
{
return value.Client;
}
}
return null;
}
}
And so I am left with a conundrum, this implementation has basically the same requirements that ClientUserService has (a specific header must exist on the web request) and it provides a service the same way that the latter does (associated with a behavior on the mediatr pipeline), but it also depends on my configuration details, which I am putting in Infrastructure because that is where I am configuring CORS and authentication.
Describe the bug
A 404 occurs trying to load favico in Windows 10 Pro x64:
Failed to load resource: the server responded with a status of 404 (Not Found) :52178/favicon.ico:1
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No 404s should occur on page load.
Describe the bug
When loading the main page of the client application in Chrome, the following error occurs once in the browser console. The application is being run from Windows 10 Pro x64.
core.js:7187 ERROR Error: Uncaught (in promise): Error: Could not load settings for 'ca_sln.WebUI'
Error: Could not load settings for 'ca_sln.WebUI'
at AuthorizeService.<anonymous> (authorize.service.ts:179)
at Generator.next (<anonymous>)
at fulfilled (authorize.interceptor.ts:10)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:30892)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:30873)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)
at resolvePromise (zone-evergreen.js:797)
at zone-evergreen.js:707
at fulfilled (authorize.interceptor.ts:10)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:30892)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:30873)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)
The following error occurs twice:
ERROR Error: Could not load settings for 'ca_sln.WebUI'
at AuthorizeService.<anonymous> (authorize.service.ts:179)
at Generator.next (<anonymous>)
at fulfilled (authorize.interceptor.ts:10)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:30892)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:30873)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The page should not launch with errors.
Hello,
I'm new to .net core and just began to clean arch, but I got some trouble to getting started
Can you help me?
`
public class TodoList
{
public int Id { get; set; }
public virtual ApplicationUser AssignTO { get; set; }
}
`
I can't do this because Applicationuser comes from Infrastructure, and my object entity comes from the domain
I have a circular dependency ....
Is your feature request related to a problem? Please describe.
The pipeline behaviour regarding the authorize attribute is always trying to resolve the user. Maybe this should be more dynamic regarding the AllowAnonymous
or the not existing Authorize
attributes.
Describe the solution you'd like
Respect the filters set to the route.
Describe alternatives you've considered
Replacing FirstAsync
with FirstOrDefaultAsync
and user.UserName
with user?.UserName
.
Additional context
-
Creating a separate class library which handles all DI could possible remove direct Infra dependency from WebUI. Share your thoughts
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.