Giter Site home page Giter Site logo

dotnet-architecture / eshoponweb Goto Github PK

View Code? Open in Web Editor NEW
9.9K 481.0 5.3K 59.7 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%
asp-net-core asp-net-core-mvc clean-architecture clean-code ebook microsoft ddd ddd-architecture ddd-patterns ddd-sample

eshoponweb's Introduction

Build Status

Microsoft eShopOnWeb ASP.NET Core Reference Application

Sample ASP.NET Core reference application, powered by Microsoft, demonstrating a single-process (monolithic) application architecture and deployment model. If you're new to .NET development, read the Getting Started for Beginners guide.

A list of Frequently Asked Questions about this repository can be found here.

Overview Video

Steve "ardalis" Smith recorded a live stream providing an overview of the eShopOnWeb reference app in October 2020.

eBook

This reference application is meant to support the free .PDF download ebook: Architecting Modern Web Applications with ASP.NET Core and Azure, updated to ASP.NET Core 8.0. Also available in ePub/mobi formats.

You can also read the book in online pages at the .NET docs here: https://docs.microsoft.com/dotnet/architecture/modern-web-apps-azure/

The eShopOnWeb sample is related to the eShopOnContainers sample application which, in that case, focuses on a microservices/containers-based application architecture. However, eShopOnWeb is much simpler in regards to its current functionality and focuses on traditional Web Application Development with a single deployment.

The goal for this sample is to demonstrate some of the principles and patterns described in the eBook. It is not meant to be an eCommerce reference application, and as such it does not implement many features that would be obvious and/or essential to a real eCommerce application.

VERSIONS

The main branch is currently running ASP.NET Core 8.0.

Older versions are tagged.

Topics (eBook TOC)

  • Introduction
  • Characteristics of Modern Web Applications
  • Choosing Between Traditional Web Apps and SPAs
  • Architectural Principles
  • Common Web Application Architectures
  • Common Client Side Technologies
  • Developing ASP.NET Core MVC Apps
  • Working with Data in ASP.NET Core Apps
  • Testing ASP.NET Core MVC Apps
  • Development Process for Azure-Hosted ASP.NET Core Apps
  • Azure Hosting Recommendations for ASP.NET Core Web Apps

Running the sample using Azd template

The store's home page should look like this:

eShopOnWeb home page screenshot

The Azure Developer CLI (azd) is a developer-centric command-line interface (CLI) tool for creating Azure applications.

You need to install it before running and deploying with Azure Developer CLI.

Windows

powershell -ex AllSigned -c "Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression"

Linux/MacOS

curl -fsSL https://aka.ms/install-azd.sh | bash

And you can also install with package managers, like winget, choco, and brew. For more details, you can follow the documentation: https://aka.ms/azure-dev/install.

After logging in with the following command, you will be able to use the azd cli to quickly provision and deploy the application.

azd auth login

Then, execute the azd init command to initialize the environment.

azd init -t dotnet-architecture/eShopOnWeb 

Run azd up to provision all the resources to Azure and deploy the code to those resources.

azd up 

According to the prompt, enter an env name, and select subscription and location, these are the necessary parameters when you create resources. Wait a moment for the resource deployment to complete, click the web endpoint and you will see the home page.

Notes:

  1. Considering security, we store its related data (id, password) in the Azure Key Vault when we create the database, and obtain it from the Key Vault when we use it. This is different from directly deploying applications locally.
  2. The resource group name created in azure portal will be rg-{env name}.

You can also run the sample directly locally (See below).

Running the sample locally

Most of the site's functionality works with just the web application running. However, the site's Admin page relies on Blazor WebAssembly running in the browser, and it must communicate with the server using the site's PublicApi web application. You'll need to also run this project. You can configure Visual Studio to start multiple projects, or just go to the PublicApi folder in a terminal window and run dotnet run from there. After that from the Web folder you should run dotnet run --launch-profile Web. Now you should be able to browse to https://localhost:5001/. The admin part in Blazor is accessible to https://localhost:5001/admin

Note that if you use this approach, you'll need to stop the application manually in order to build the solution (otherwise you'll get file locking errors).

After cloning or downloading the sample you must setup your database. To use the sample with a persistent database, you will need to run its Entity Framework Core migrations before you will be able to run the app.

You can also run the samples in Docker (see below).

Configuring the sample to use SQL Server

  1. By default, the project uses a real database. If you want an in memory database, you can add in the appsettings.json file in the Web folder

    {
       "UseOnlyInMemoryDatabase": true
    }
  2. Ensure your connection strings in appsettings.json point to a local SQL Server instance.

  3. Ensure the tool EF was already installed. You can find some help here

    dotnet tool update --global dotnet-ef
    
  4. Open a command prompt in the Web folder and execute the following commands:

    dotnet restore
    dotnet tool 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
    

    These commands will create two separate databases, one for the store's catalog data and shopping cart information, and one for the app's user credentials and identity data.

  5. Run the application.

    The first time you run the application, it will seed both databases with data such that you should see products in the store, and you should be able to log in using the [email protected] account.

    Note: If you need to create migrations, you can use these commands:

    -- create migration (from Web folder CLI)
    dotnet ef migrations add InitialModel --context catalogcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj -o Data/Migrations
    
    dotnet ef migrations add InitialIdentityModel --context appidentitydbcontext -p ../Infrastructure/Infrastructure.csproj -s Web.csproj -o Identity/Migrations
    

Running the sample in the dev container

This project includes a .devcontainer folder with a dev container configuration, which lets you use a container as a full-featured dev environment.

You can use the dev container to build and run the app without needing to install any of its tools locally! You can work in GitHub Codespaces or the VS Code Dev Containers extension.

Learn more about using the dev container in its readme.

Running the sample using Docker

You can run the Web sample by running these commands from the root folder (where the .sln file is located):

docker-compose build
docker-compose up

You should be able to make requests to localhost:5106 for the Web project, and localhost:5200 for the Public API project once these commands complete. If you have any problems, especially with login, try from a new guest or incognito browser instance.

You can also run the applications by using the instructions located in their Dockerfile file in the root of each project. Again, run these commands from the root of the solution (where the .sln file is located).

Community Extensions

We have some great contributions from the community, and while these aren't maintained by Microsoft we still want to highlight them.

eShopOnWeb VB.NET by Mohammad Hamdy Ghanem

FShopOnWeb An F# take on eShopOnWeb by Sean G. Wright and Kyle McMaster

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

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.

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!

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?

[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 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>

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:"

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.

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.

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)

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

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

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

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

[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

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.

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?

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.

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?

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>

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

Update Logo

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

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

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

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?

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.

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.

Error when launching web project

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

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.

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?

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

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 ?

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.

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.