Questions tagged [asp.net-core]

A free, open source and cross platform web development framework for building .NET web applications.

Filter by
Sorted by
Tagged with
92
votes
15answers
17k views

Should we design our code from the beginning to enable unit testing?

There's a debate going on in our team at the moment as to whether modifying code design to allow unit testing is a code smell, or to what extent it can be done without being a code smell. This has ...
32
votes
5answers
20k views

Should I check if something exists in the db and fail fast or wait for db exception

Having two classes: public class Parent { public int Id { get; set; } public int ChildId { get; set; } } public class Child { ... } When assigning ChildId to Parent should I check first if ...
10
votes
2answers
4k views

ASP.Net Core: ViewComponent vs EditorTemplate/DisplayTemplate vs @inject

So I was searching for a good way in ASP.Net Core to create some "controls" that render into a view. So far I found there are 3 options, and I wanted to get some feedback on them. ViewComponents: ...
9
votes
2answers
3k views

Which data should be stored as `Claim`?

In ASP.Net Core, I find Claims authorization is very not-concrete method. We can add anything as ClaimType and ClaimValue pair; groups, firstname, lastname, brithdate, canAccessThisURI, isEditor, etc.....
8
votes
3answers
2k views

What are the differences between .NET Framework, ASP.NET, .NET Core, ASP.NET Core and .NET Standard?

thanks to the .NET evolution, today we have a lot of different frameworks and technologies. I'm very confused about the differences about it. What is the difference between: .NET Framework ASP.NET ....
8
votes
2answers
4k views

Can a caller abort an execution of code invoked by HTTP request?

A third party that is going to make HTTP requests to the API that I'm building, requires that the API responds in less than one second. My question is, do they have a way (literally any way, within ...
7
votes
3answers
1k views

Ambient dependency injection through static service locator

After some googling I found some debates about whether constructor injection or property/field injection is better, but there is yet another alternative that strikes me as more beneficial. In most ...
7
votes
6answers
574 views

Client side web development - dealing with authentication during development

We are beginning development of an Angular 2 application. Our back-end will be using ASP.NET Core WebAPI. Although my subject calls out authentication, this also applies to any API service that is-...
6
votes
2answers
5k views

In ASP.Net Core , how does one resolve circular references?

I was working on migrating over a project which uses a static logger, and a static email service. The email service logs emails sent, and the logger service sends an email if there are any logging ...
6
votes
1answer
3k views

Should .NET Core class libraries register their own implementations?

Our team had recently a big struggle of deciding whether it is a good practice or not for the .NET Core class libraries to register their own implementations by the fact of providing a ...
4
votes
2answers
175 views

Multiple Applications, how to bring them together?

I have 7 different .NET Core applications (solutions). All supporting a different workflow such as customer request, request for change and much more. However, they do share a similar goal (that is to ...
4
votes
4answers
3k views

Should it be a claim, a role or a policy?

The distinction between roles and claims is that roles describe a set of users and claims describe a property of a user. So there can be a role "Administrator", but there can also be a claim "...
4
votes
2answers
4k views

What is best practice to share a database in ASP.NET Core with other projects?

I have multiple ASP.NET Core web applications that need to share an employee database. I want to be able to write the Repository and Models once and use it in multiple projects. What is best practice ...
4
votes
1answer
2k views

Is it safe to add extra role claims to the asp.net identity?

I am using the Azure AD authentication provider for the asp.net web application and I wish to add extra role claims (based on custom application logic, those cannot be provided from Azure AD). ...
4
votes
4answers
1k views

Mapping API models(DTOs) to rich domain models

How to implement HTTP's PUT that works with child collections when using DDD's rich domain models? Let's say we've got an aggregate root with a nicely encapsulated collection of items: (I omitted ...
4
votes
1answer
2k views

MVC Core Repository Pattern for Multiple Lookup tables

We have Customer transactional table with multiple lookup tables with foreign keys. We want to create dropdown menus using these lookup tables, when CustomerService creates a Customer order ...
3
votes
2answers
185 views

How should domain services be referenced?

I'm working on a test project, with the intention of using DDD. So far I have this basic project structure: My question is: How should the Core.Domain.Services be referenced? do I create an ...
3
votes
1answer
205 views

Internationalization in .net core

I am currently in the process of developing an ASP.NET Core application which requires internationalization to Russian. I have been reading over the documentation that Microsoft provide for .NET Core ...
3
votes
3answers
153 views

How to clone an object graph and keep relationships of objects intact?

In my ASP.net core application with Angular 2+ client, I work with a complicated object graph. In the object graph I have some objects with references to each other. I have a simplification included ...
3
votes
0answers
285 views

Onion Architecture: Should Service Layer contain DB Context?

In Onion Architecture, we have repository layer which conducts Crud Operations (simple insert, delete, update). (Applying Entity Framework with database) Onion Architecture Additionally , we have ...
3
votes
0answers
175 views

Clean Architecture - What is the difference between Use Cases and Core Services?

I'm trying to apply Clean Architecture to a simple ASP.NET MVC Core app by following Microsoft's ASP.NET architecture guidelines and their eShopOnWeb sample project. In the standard Clean ...
3
votes
2answers
194 views

Queueing async code to execute later

I have a website with basic crud operations that involve data and photos. I also need to extract the metadata for the photos that are being uploaded. My original implementation did not have var puts =...
3
votes
0answers
375 views

Design a Windows Service with self-hosted ASP.NET Core Web Services and UPD port listeners

I'm designing a software platform in automation that is responsible of many different tasks like: Core functions Driver interface for machines UDP listener for machine messages from PLC UDP listener ...
3
votes
0answers
2k views

How to use .NET Core in Production [closed]

We´re on the way to newly develop a WebApplication. We wan´t to make it a ASP.NET MVC app and we thought, that it will be the best approach to start with .NET Core. We started with project type ASP....
2
votes
4answers
262 views

Can I assume nobody deletes user generated content off my server's file system?

Situation Currently I'm developing a web service in which users can (generally) upload binary files. These files are stored in the file system of the host OS and some additional metadata about the ...
2
votes
2answers
655 views

C# extension methods design patterns and usage guidelines?

C# extension methods have seen a rise in usage over recent years. The offical microsoft guidelines on usage state: "In general, we recommend that you implement extension methods sparingly and only ...
2
votes
2answers
2k views

C# Namespace Ordering Coding Convention

Is there a general coding convention in ordering namespaces? Is it always order of importance, or alphabetical? Currently I order by main important ones first. I know it does not affect program, just ...
2
votes
1answer
2k views

Is .NET ASP MVC core suitable for rapid web development?

I currently work for a company who builds web applications for businesses and entrepreneurs, typically 4-6 projects per year. We currently use Laravel/PHP which allows us to build apps relatively ...
2
votes
1answer
2k views

C# .Net Core API design - interfaces vs DTOs

I'm designing a relatively simple web application using .net core. I've mostly done desktop development in my career so far, so I'm a bit new to the nuances between desktop and web development. In ...
2
votes
1answer
268 views

Abstraction for Account transactions and balance

We have 10 applications which updates account balance table, without logging credit/debit line transactions (not sure why). They all have the pretty much same SQL Statement. In order to get out of ...
2
votes
1answer
528 views

Best practices for translatable models in Entity Framework Core 2.1+

I'm building an Entity Framework Core-backed ASP.NET Core RESTful service and I have entities / models such as Product, Document etc with description in multiple languages. I want to be able to ...
2
votes
1answer
323 views

ASP.Net MVC When ViewModel properties vs Ajax calls in view

When is it more appropriate to use asynchronous calls from the view to get data vs prepopulating it server-side when creating the instance of the viewmodel? For instance, if my view has some dropdown ...
2
votes
1answer
4k views

Data Encryption in Data Layer with ASP.NET Core Entity Framework

I am currently designing a web application where the data needs to be stored encrypted. Planned technologies used: ASP.NET Core API ASP.NET Core Entity Framework MS SQL Server 2016 any Web Frontend ...
2
votes
1answer
284 views

DDD with web api, validation in domain or application layer?

I saw a lot of discussion, but I don't know how to do it in a real world. I understand that validation duplication in the client and server is needed. But how to elegantly validate in server and ...
2
votes
1answer
81 views

Validation layer of clustered WebApi solution

Currently I have a design problem, which I am not sure how exactly to solve and what would be the best approach. So what I have is a ASP.NET Core WebApi project which is actually clustered solution. ...
2
votes
1answer
1k views

Table Per Concrete Type in Entity Framework Core

I'm trying to port code from entity framework 6 (EF6) to entity framework core 2.0 (EF-Core) and have ran into a dead end. In my EF6 code, I have a base class called Record which defines the base ...
2
votes
2answers
4k views

Asp.net mvc web api model validation best practice

I have an annoying code smell in my asp.net core api that I am passing around, and I can't come up with a way to fix. In an MVC controller action, usually there is a very straight forward logic, at ...
2
votes
3answers
740 views

What models do I have? And what's a layer?

I've gone through a few tutorials in ASP.NET Core MVC, and I've built a little app (for looking at problems in old exams) that looks roughly like this: Solution Project ... Models ...
2
votes
2answers
1k views

Replace ASP.NET Core's DI container with external container

I'm using ASP.NET Core's builtin DI container. It's missing some features I need, so I need to use a third-party container. The top ones on Nuget are Autofac and StructureMap. SimpleInjector is ...
2
votes
0answers
75 views

Extending IdentityUser with nullable foreign key to another IdentityUser

I'm working on a framework which builds on .net core Identity. Let's say I wanted to extend the IdentityUser<TKey> class with a ParentUserId property while the developer should still be able to ...
2
votes
0answers
722 views

Dependency Injection: Creating object factories vs. using inversion of control containers [closed]

When requiring to use dependency injection, I always use IoC containers such as Ninject, Unity, or the built-in one in ASP.Net Core MVC. However, I've just come across the idea of "why not creating an ...
1
vote
1answer
165 views

If we are allowing anonymous users to register inside our web site, how we can prevent hackers from occupying others' email address

I am planning to start a new asp.net core MVC web application. One of the features we are having is that anonymous users can register inside our web application by entering their email addresses. then ...
1
vote
1answer
3k views

What is the difference between a Query Object and a Repository?

What is the difference between Query Object and Repository? Martin Fowler 'Patterns of Enterprise Architecture': “an object that represents a database query.”, Also should a QueryObject always be ...
1
vote
5answers
781 views

Correct usage of HTTP VERBS in custom REST implementation

I have a server-side service (using ASP.NET Core) that should provide a REST API to various clients. Behind the service, I use a SQL server for data storage. The controller has the following route ...
1
vote
1answer
1k views

How to choose between a library and shared project?

I am working on a set of .NET Core 2.0 Microservices together with some other developers. I wrote some code to add my own custom logging as described here. My logger sends the logging messages to an ...
1
vote
2answers
96 views

Scaling Out re-design approach?

My current web app provides a service to clients on a single site. It is NOT eBay, but I will explain using eBay as an analagous service we can all understand. A client sets up a page, and other peer ...
1
vote
3answers
690 views

Domain Events, CQRS, and dependency resolution in handlers

Currently: ASP.NET Core 2.2. I've been doing quite an extensive research in this topic (Domain Driven Design used together with Clean Architecture): DDD: Where to place domain event handlers? And I'...
1
vote
2answers
3k views

Command/query instead of repository

I'm thinking about implementation of command/query pattern and I have following solution: Interface for queries: public interface IQuery<TResult, TArg> where TResult: class where ...
1
vote
2answers
67 views

Custom services container for ASP .NET core business layer

My model classes (business layer/library of ASP .NET core solution) uses a number of services (IOrmService, IEmailService, IFileService, IHtmlToPdfConverter etc.). Different models requires different ...
1
vote
1answer
399 views

How to remove code duplication in Web API versioning

I'm working with ASP.NET core web API project, where I have 8 controllers, multiple DTOs being used for request and response and mappers to map models(also used in the web app) with DTOs. Recently, ...