Coder Social home page Coder Social logo

dotnet-architecture / eshoponweb Goto Github PK

View Code? Open in Web Editor NEW
10.1K 10.1K 5.4K 59.71 MB

Sample ASP.NET Core 8.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.

Home Page: https://docs.microsoft.com/dotnet/standard/modern-web-apps-azure-architecture/

License: MIT License

C# 71.04% CSS 3.27% JavaScript 0.01% Dockerfile 0.31% HTML 19.53% SCSS 2.94% Bicep 2.91%
architecture asp-net-core asp-net-core-mvc clean-architecture clean-code ddd ddd-architecture ddd-patterns ddd-sample design-patterns dotnetcore ebook efcore microsoft monolith rest-api software-architecture

eshoponweb's People

Contributors

alexandrshad avatar ardalis avatar bamurtaugh avatar cesardelatorre avatar dependabot[bot] avatar efleming18 avatar erjain avatar hemantkd avatar hutchcodes avatar jamesmontemagno avatar khairuzzaman avatar michelcedric avatar moientajik avatar mpelesh avatar nemi-chand avatar nishanil avatar noellelc avatar nrkirby avatar nudemeth avatar onurbiyik avatar shadynagy avatar srushtipasari94 avatar sughosneo avatar timheuer avatar twerthi avatar vishipayyallore avatar wkalmar avatar yigith avatar youssef1313 avatar zedy-wj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eshoponweb's Issues

Question for form submit

In Views/Catalog/Index.cshtml, there is no submit in following form. How does it work?

    <form asp-action="Index" asp-controller="Catalog" method="post">
        <label class="esh-catalog-label" data-title="brand">
            <select asp-for="@Model.BrandFilterApplied" asp-items="@Model.Brands" class="esh-catalog-filter"></select>
        </label>
        <label class="esh-catalog-label" data-title="type">
            <select asp-for="@Model.TypesFilterApplied" asp-items="@Model.Types" class="esh-catalog-filter"></select>
        </label>
        <input class="esh-catalog-send" type="image" src="images/arrow-right.svg" />

    </form>

eBook is missing a verb

Under "Apps and Single Page Apps (SPAs)" section, in "Summary", this sentence needs the verb "use":
"You should traditional web applications when:" --> "You should use traditional web applications when:"

Migrations with Infrastructure as NetStandard library

How are migrations managed when the Infrastructure library is a .NET Standard 2.0 target framework?

This library contains the AppIdentityDbContext through Microsoft.AspNetCore.Identity with migrations through Microsoft.EntityFrameworkCore.Tools packages, but running a migration results in:

Startup project 'src\Infrastructure' targets framework '.NETStandard'. There is no runtime associated with this framework, and projects targeting it cannot be executed directly. To use the Entity Framework Core Package Manager Console Tools with this project, add an executable project targeting .NET Framework or .NET Core that references this project, and set it as the startup project; or, update this project to cross-target .NET Framework or .NET Core.

Namespaces need standardization

In the ApplicationCore project some of the classes are defined in the ApplicationCore.* namespace, some are defined in Microsoft.eShopWeb.ApplicationCore.* namespace. The default namespace is ApplicationCore

Similar issue in the Web project where most of the project is under Microsoft.eShopWeb.*, but a few classes have been created in Web.* which is the default namespace.

As someone who is reading through this trying to my bearings it would be helpful if this were standardized in some way. Either all namespaces starting with Microsoft.eShopWeb or just eShopWeb or even no global name space and each project starts it's namespacing with it's project name.

I'll be standardizing for myself, and would be happy to submit a PR for whatever direction the maintainers think makes the most sense.

Can't create SQL Server databases

Hi team,

First off, thank you for creating this sample project! I've successfully run the project using the in memory db with no issues. I followed the instructions on the README and attempted to run the migrations to create the initial Catalog and Identity databases.

I've got .NET Core 2 SDK installed on my Windows 10 machine. I have SQL Server 2014 installed as well.

  1. Modified Program.cs as mentioned in the README file
  2. Verified appsettings.json connection strings. I've modified these a few times, but nothing seems to work:
// these are the default connection strings included with the project
  "ConnectionStrings": {
    "CatalogConnection": "Server=(localdb)\\ProjectsV13;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;",
    "IdentityConnection": "Server=(localdb)\\ProjectsV13;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;"
  },
  1. Navigate to the Web folder: C:\Users\Danny\Documents\GitHub\eShopOnWeb\src\Web
  2. Run dotnet restore - works fine
dotnet ef database update -c catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj
dotnet ef database update -c appidentitydbcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj

Neither of these work.

Here is the large log shared via a Gist:
https://gist.github.com/DannyAllegrezza/7848a91c241ade453d4cb45598665252

I'm not sure where this problem stems from. It seems as though the database is never being created, which leads to the

System.Data.SqlClient.SqlException (0x80131904): Cannot open database "Microsoft.eShopOnWeb.Identity" requested by the login. The login failed.
Login failed for user 'DESKTOP-HICGBT3\Danny'.

errors.

I've created plenty of LocalDB databases with no issues.

Here is the final error:

Error Number:4060,State:1,Class:11
An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: One or more errors occurred. (Cannot open database "Microsoft.eShopOnWeb.Identity" requested by the login. The login failed.

Login failed for user 'DESKTOP-HICGBT3\Danny'.)

Unable to create an object of type 'CatalogContext'. Add an implementation of 'IDesignTimeDbContextFactory<CatalogContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.

Any thoughts on this?

BaseSpecification Code Improvement

The public constructor makes no sense in an abstract class BaseSpecification.

public abstract class BaseSpecification : ISpecification
{
public BaseSpecification(Expression<Func<T, bool>> criteria)
......
}

As the BaseSpecification can only be initiated by derived types. Please change the constructor to protected as following:

protected BaseSpecification(Expression<Func<T, bool>> criteria)

The functional tests do not work with RazorPages

I tried implementing the functional tests for my own project but I am using RazorPages and I get the following error:

The type or namespace name 'RazorPages' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)

The RazorPages project runs from Visual Studio but running it from the TestServer gives the previous error. I tried adding references to Microsoft.AspnetCore.All directly in the test project but that did not affect anything.

Pagination not being reset

Once being on the page number 2 you change filters, after refresh page is still set to 2. Thus there are no results as filtered products fit on one page entirely.

Same clicking on the logo shall return current page to 1 (although can keep value of selected filters - it works this way now).

I have tried to change it on my own, however this is just the beginning of journey with Asp.net. Too early on my learning curve.

Error when launching web project

InvalidOperationException: Scheme already exists: Identity.Application
Microsoft.AspNetCore.Authentication.AuthenticationOptions.AddScheme(string name, Action configureBuilder)
Kindly help. Thanks

Database Context in Presentation Layer, Why?

Can somebody say why is the CatalogContext defined in the Web project?
This is related to the Data Access Layer and I don't see why in a sample application it is in Presentation Layer.

Not able to run WebRazorPages on Linux server

Hi,
First i have added docker support to both applications - Web and WebRazorPages and it's working fine at my local and i am able to run both applications.
Then i am trying to deploy this application on Linux server. Web is deploying fine but for WebRazorPages it's giving me following error:
'Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409'
Please suggest how can i resolve this error.

I have one more query, Docker inbuilt added container ip for both applications, then how can we access these application outside.
Do we need to redirect these ip's ?
Please also guide on these points.

Thanks!
Rajni

ID-properties are of type int - not always good for existing DB

In ApplicationCore/Entities/BaseEntity.cs you define that the ID-property of an entity is always of type int and always named "Id". I've got a lot of older apps where the ID-property (PK-column in DB) is of different type like string or GUID and has a different name (often Entity+"_ID", but also some complete other naming schemes).
You use the same assumption about the type of ID-property onwards in the interfaces IRepository and IImageService (you assume that the ID of an image is of type int).
Infrastructure/Data/EfRepository then implements this interface and so also here int is backed in.
Is it possible for you to make BaseEntity having a "generic" type for the ID-property and also build in a way of having a different name for the ID-property on a per-entity-base?
Regards
Dietmar

Referencing ApplicationCore from Infrastructure and Web problem

Where is the problem with referencing ApplicationCore project from Infrastructure or Web project?

Cloned this repository, or tried new, scratch solution. When referencing .NET Standard 2.0 class library from .NET Core 2.0 project, problem with compiling or IntelliSense appears (Cannot resolve symbol 'ApplicationCore').

Am I only one with this problem?

Visual Studio CE 2017 v15.3.5

Dependency AspNetCore.Http in Infra or other project?

I have a situation where I need to have ICurrentUser on both projects

1 - ApplicationCore for any specific rule with user or tenant
2 - Infra - For global filter in dbContext or repository

The implementation of ICurrentUser have a dependency the Microsoft.AspNetCore.Http

For example:

  public class CurrentUser: ICurrentUser
    {
        private readonly IHttpContextAccessor _accessor; //HERE

        public UserSession (IHttpContextAccessor accessor)
        {
            _accessor = accessor;
        }
        public string Name => _accessor.HttpContext.User.Identity.Name;
        public int? TenantId => int.Parse (_accessor.HttpContext.User.Claims.FirstOrDefault (x => x.Type == "TenantId"). ToString ());
        public bool IsAuthenticated => _accessor.HttpContext.User.Identity.IsAuthenticated;
    }

I have as dependency Microsoft.AspNetCore.Http, and need to be used in ApplicationCore and Infra (Data / DbContext)

Would it be correct to leave this implementation and dependency on Infra? Or maybe in another layer (eShopOnWeb.Shared for example)? Where would be the best approach?

Suggestions?

How to migrate a database

More than one DbContext was found. Specify which one to use. Use the '-Context' parameter for PowerShell commands and the '--context' parameter for dotnet commands.
I dot't know

Question about the repository and specification design

The repository and specification design looks good, but when I use it in my work, I found it hard to handle when the logic is a little more complicate.
For example, when my api accepts a new Student object For create, I have to check if the student'scardnumber already exists, do i define a specification to do this check? It's annoying to do a lot of such works.

Clean Architecture with Identity

Hi,
We're starting a major new web project, and wanted to start developing in .Net Core, rather than the MVC5 that we're used to.
I've read through some of the Architecture guide, and was interested in moving to using the Clean Architecture approach. I was hoping that this sample application would indicate how this could be used in an ASP.Net Core web application, but it seems to duck some of the issues that it's trying to promote.
Specifically, we need to have a relationship between our business entities, and the application user, but this project doesn't implement this aspect.
As a scenario that would crop up in an eShop, it's likely that a user of the site would need to see their order history. So, in EF, you might have an Order entity, which has a UserId property, and then a navigation property to the ApplicationUser. Similarly, the ApplicationUser might have a navigation property to a List of 'Order'.
In the sample, ApplicationUser isn't in the Core project, but is only in the Infrastructure project, so how would you implement this?
I realise that there is a solution to this, presumably using interfaces for the Identity classes in the Core project, but it would be useful to have this in the sample project, if it is intended to get developers up and running quickly.
If I've missed anything obvious, let me know.
Thanks!

Question about loading related data in repository

Hello,

How can i use multiple include statements inside a repository?
Why isn't my code below working?
var result = _dbContext.Object .Include(ans => ans.ObjectOther) .Include(ans => ans.ObjectOther.Select(o => o.ObjectOtherDetail)) .SingleOrDefault(a => a.Id == id);
Regards

Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1 (

I have something weird after downloading, restoring and rebuilding I get this:

Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.1.
Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.1.
Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.1.
NuGet package restore failed

the weird thing is that even with the errors, it says build succeeded.

Errors when trying to create databases

Hello,
When trying to create databases by using this commands

Open a command prompt in the Web folder and execute the following commands:
dotnet restore
dotnet ef database update -c catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj
dotnet ef database update -c appidentitydbcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj

I have following errors in powershel with migrations. Any advice for this issue?
2018-04-28 1
2018-04-28 2

Nested includes in ISpecification

Hi, I have been looking at ISpecification and the way the includes are added. Could something similiar be implemented for nested includes, that later are translated to ThenInclude in IQueryable?

Wiki Images

Apparently the simplest way to add images to a wiki (without bloating the code repo itself) is to attach them to issues and reference them by URL in the wiki...

image

image

image

image

image

image

image

image

image

image

image

image

image

image

CQRS MediatR

In this architecture, mediatR (Command/Handlers) are implemented in ApplicationCore?

Why Serivces in web project? (CatalogService)
Why not use auto mapper for model => viewModel ?

[Feature] Adding eShopOnSPA (Angular) Example

First of all thanks a lot for this great and very useful repo 💯

It will be Great to Add an eShopOnSPA (Angular) Example to this Repo without all the complications of microservices and containers in here

netcoreapp2.0 vs netcorestandard2.0 Compatibility issues and missing references won't let the solution build

About to tackle numerous build errors like the following. If you've already solved this, please share your suggestions. Thanks in advance.

Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'SerializationInfo' does not exist in the namespace 'System.Runtime.Serialization' (are you missing an assembly reference?) ApplicationCore G:\code\eShopOnWeb\src\ApplicationCore\Exceptions\BasketNotFoundException.cs 11 Active

Severity Code Description Project File Line Suppression State
Error Package Microsoft.AspNetCore.StaticFiles 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.AspNetCore.StaticFiles 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)

Severity Code Description Project File Line Suppression State
Warning MSB3243 No way to resolve conflict between "System.Globalization, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Globalization, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "System.Globalization, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily. Infrastructure C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 1964

Cannot run update-database

PM> dotnet ef database update -c catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj
C:\Program Files\dotnet\sdk\2.1.104\Microsoft.Common.targets(127,3): error MSB4024: The imported project file "C:\Users\MHerb\Downloads\eShopOnWeb\src\Infrastructure\obj\Infrastructure.csproj.EntityFrameworkCore.targets" could not be loaded. Unexpected end tag. Line 25, position 4. [C:\Users\MHerb\Downloads\eShopOnWeb\src\Infrastructure\Infrastructure.csproj]
Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
PM>

Using Infrastructure.Logging in Application Core

Implementation of Logging is part of the Infrastructure. Application Core will have it's own service implementation, for instance in this project it is UriComposer. There will be logging required in ApplicationCore, since it is not just the domain entities. How do I make use of Logger in ApplicationCore? Shouldn't this Logger be shared independent project out of infra and core?

[Book improvement] Book Feature Comparison Table Missing Containers

Sorry if this is the wrong place but the book does a great job detailing architecture. On page 107, there is a features table which I think has a lot of value. Unfortunately it's only showing 3/4 of the methods you mentioned. Containers and Azure Container Service is left off. Did I miss something or is there a good reason to leave it off or could it just be combined with one of the others on the chart like VM?

Cannot run WebRazorPages after cloning

IDE: Visual Studio Community 2017
Web Server: IIS Express (in IDE)
OS: Windows 7

Stack trace `System.ArgumentNullException: Value cannot be null. Parameter name: userName at Ardalis.GuardClauses.GuardClauseExtensions.NullOrEmpty(IGuardClause guardClause, String input, String parameterName) at ApplicationCore.Services.BasketService.d__7.MoveNext() in I:\opensource\eShopOnWeb\src\ApplicationCore\Services\BasketService.cs:line 47 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.eShopWeb.RazorPages.ViewComponents.Basket.d__3.MoveNext() in I:\opensource\eShopOnWeb\src\WebRazorPages\ViewComponents\Basket.cs:line 26 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentHelper.d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.eShopWeb.RazorPages.Pages._LoginPartial_View.d__24.MoveNext() in I:\opensource\eShopOnWeb\src\WebRazorPages\Pages\_LoginPartial.cshtml:line 61 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.RazorView.d__16.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.RazorView.d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.AspNetCore.Mvc.Razor.RazorView.d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.d__60.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.d__57.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.eShopWeb.RazorPages.Pages._Layout_View.<b__42_13>d.MoveNext() in I:\opensource\eShopOnWeb\src\WebRazorPages\Pages\_Layout.cshtml:line 35 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.d__30.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.eShopWeb.RazorPages.Pages._Layout_View.d__42.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.RazorView.d__16.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.RazorView.d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Microsoft.AspNetCore.Mvc.Razor.RazorView.d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Razor.RazorView.d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__24.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.d__7.MoveNext()`

Due to empty userName which returned from GetUsername() in Basket.cs. User.Identity.Name is empty and this is the first run, so no basket cookie. I can manually fix it by modifying return statement to return Guest as a default value of the method.

private string GetUsername()
{
      if (_signInManager.IsSignedIn(HttpContext.User))
      {
           return User.Identity.Name;
      }
      return GetBasketIdFromCookie() ?? "Guest";
}

I can help sending PR if you are ok with it.

BasketWithItemsSpecification Code Improvement

In BasketWithItemsSpecification constructor the code is calling AddInclude which is a virtual method.
This could lead to a possible problem that if you make a virtual method call in a constructor, and it is not the most derived type in its inheritance hierarchy, that it will be called on a class whose constructor has not been run, and therefore may not be in a suitable state to have that method called.

public BasketWithItemsSpecification(int basketId)
:base(b => b.Id == basketId)
{
AddInclude(b => b.Items);
}

I would suggest making the BasketWithItemsSpecification as a "sealed" class.

Update Logo

Need to update logo so it doesn't refer to eShop OnContainers, but rather to OnWeb.

When to use service or repository

IOrderRepository is used in OrderController and IOrderService is used in BasketController
Why you are not using IOrderService in both of the locations?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.