Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
0 votes
1 answer
131 views

How to handle duplicate validation logic with CQRS pattern

I am implementing a CQRS pattern in ASP.NET Core with MediatR, and I am wondering what the general consensus is for handling duplicate validation logic for queries/commands which operate on the same ...
user avatar
0 votes
2 answers
203 views

Which strategy to use to create object instances

I have this use case (I've simplified it): Each student can apply for one or multiple activities. As of now we only have Swimming activity onboarded on the system, but we expect to have more. Base ...
user avatar
  • 109
0 votes
0 answers
13 views

Whats the common "flow" for authentication using ADFS and OpenId Connect when building an API?

Im trying to "grasp" how a user should authenticate to our API. Our API is setup to use OpenID Connect thats issued by an ADFS-server. However.. as a "consumer" of our application, ...
user avatar
  • 193
0 votes
2 answers
77 views

Is it bad style to share a Model class between two API Endpoints?

I have the following scenario: My .NET Core API has two Endpoints CreateProduct and UpdateProduct. The only difference between the two will be that UpdateProduct will need to know the ID of the ...
user avatar
  • 495
1 vote
1 answer
50 views

Testing API with Auth0-enabled user authentication and authorization

I have a REST API and a SPA application, with Auth0 server issuing access tokens and enabling end users to login with their social identity provider. The API expects to receive a JWT access token with ...
user avatar
  • 113
1 vote
0 answers
96 views

ASP .NET Core 6 - .razor components - Routing

I come from a background in ASP.NET MVC 5 on .NET 4.8. I've been trying to wrap my head around the new razor pages, and can't seem to get routing to work, or understand it, even. I don't want to use ...
user avatar
2 votes
1 answer
161 views

In an MVC Application, What Goes Where?

In an Model-View-Controller (MVC) design pattern, What goes where? What code goes to model and to controller? I know (do I?) that business logic should be define in a model, but a lot of example I ...
user avatar
0 votes
0 answers
115 views

Microservice code reuse strategy for static classes

Hope this is the right place to post an opinion-based question like this. I'm in the process of converting an aging API monolith to a set of .NET 5/C#-based microservices and working on the code reuse ...
user avatar
0 votes
2 answers
143 views

Is it safe to use the same IoC container for your own and third-party services?

I am developing an application with ASP.NET Core with the ability to dynamically add new libraries that implement the necessary functions. They can be included at the start. I have already written ...
user avatar
0 votes
4 answers
1k views

Is it a bad practice to use Singleton for DI in Asp.net rather than Scoped, Transient whenever possible?

We had a conversation (with coworkers) about why we needed to use Singleton for Controller, Business Services, and Repositories. The reason for this, they claim, is because singleton ensures that code ...
user avatar
1 vote
2 answers
153 views

CQRS MediatR Create many items commad - is it a good practise?

I am here to ask question about: is it good practice to insert many records using CQRS and MediatR? how to structure that in terms of names and folders? A have to insert into database over 500 ...
user avatar
0 votes
0 answers
28 views

Best approach for web app that handles events and is stateful with websockets

I've got a web app in AsNetCore (.NET 5) This app subscribes to a message bus, (with MassTransit over AWS SQS transport layer), so when it receives a new event/message it reacts to it and dequeues ...
user avatar
  • 339
0 votes
0 answers
51 views

Scaling Docker Containers Question with .Net Core Worker Services

I have a fairly what I think is simple question but am completely unfamiliar with design considerations when using docker containers. So I have been trying to come up with a structure for an app that ...
user avatar
  • 101
1 vote
1 answer
209 views

How to unit test public method which internally calls many internal or private methods which are already individually unit tested [duplicate]

In our ASP.NET Core application, we have many APIs which are calling public method from the service class. Service class is implementing an Interface. Each service method (depending upon complexity ...
user avatar
  • 113
0 votes
0 answers
14 views

Consume Identity enabled WebApi in an MVC Project

I have an MVC project with no authentication. The project uses webapi as a backend to retreive and send information through the controllers. Now we need to add authentication to the webapi project as ...
user avatar
0 votes
2 answers
297 views

Where to internationalize emails in a DDD application?

I am building an application with ASP.NET Core 5.0 following DDD and the CQRS pattern. I internationalize on the presentational layer but when I send emails I send them in the application layer via an ...
user avatar
  • 21
1 vote
2 answers
392 views

One API or Two APIs one for internal use and the other for external use

I follow the Layered architecture Like this: But with two differences: I use Blazor Assembly for UI Layer. I have API layer(REST) In between the presentation layer and the service layer. My ...
user avatar
0 votes
1 answer
36 views

How best to structure this MVC or Razor Pages web application given a required tcp/ip server data source that acts like a web api?

I am rewriting an old asp.net 4.0 web forms website that exposes an application's data and logic to the web. I am moving this to a .net core mvc or razor page project. The website has minimal ...
user avatar
  • 9
0 votes
1 answer
212 views

ASP.NET Core - Using Partial Views inside a Modal window for my Add/Edit/View Details screens?

I've been developing .NET projects for the past 3 years, and on my recent web .NET projects, I've been using Partial Views for all the screens that contain Forms for Add/Update/Delete or other ...
user avatar
  • 1
0 votes
0 answers
260 views

and web api endpoint, which return html from view

I have ASP.NET 5 Web Api and need to do the following task: Add endpoint, which get cshtml page and return generated html, so it should do the same what is does razor view engine. What is better way ...
user avatar
  • 249
0 votes
0 answers
23 views

Design a multiple Asp.Net Core apps Solution

I am having an .Net Core Solution consisting of 3 Projects: The Site (Asp.Net Core MVC WebApp) The API (Asp.Net Core API) The "Common" library for shared functionality. The Common library ...
user avatar
  • 137
0 votes
2 answers
98 views

Extend the ApplicationUser class or use a Person class?

I am making a web system using Asp.Net Core with individual user accounts (Identity), and I was thinking about how I should store the users' personal information in the database. The system will have ...
user avatar
  • 131
0 votes
1 answer
353 views

Replacing in-memory queue with messaging queue service

In our application (ASP.NET core) we have events that require computations and which results need to be persisted in a database (the objects are projects that need recalculations when a property ...
user avatar
0 votes
1 answer
926 views

why controller lifetime is transient by default in asp.net core? [closed]

I know the lifetime of the controller class is transient by default, but I think it's better to be singleton. should explain to me why creators choose transient instead of singleton or scope lifetime? ...
user avatar
  • 31
2 votes
2 answers
445 views

What is suggested way to use iHostedService of .NET core or Windows service when process runs for exponential hour time (up till hours)?

I wanted to create a background job in which I want to use the retry mechanism for that I want to use the Polly. My requirement is like this: the First retry should be done after 2 hours the Second ...
user avatar
0 votes
1 answer
30 views

Getting sums of multiple leveled relations efficiently

I'm currently building an API and a web app for an internal warehouse system using NET Core. I have the core entity structure, that goes like this: "Material" has many "MaterialSubtypes&...
user avatar
  • 13
0 votes
2 answers
53 views

Strategy for Chrome timing out on a Database cleanup job which takes a long time

I have a notifications app which sends users notifications. It uses a .NET core backend, an angular frontend and Cosmos DB. Within this I have an API endpoint function which is linked to a button used ...
user avatar
0 votes
1 answer
129 views

Session Scoped Dependency Injection vs Caching in Data Access Layer

The issue at hand is that I don't want to repeatedly hit the DB to look up user information for the logged in user over the course of the many requests made within a single session. My first ...
user avatar
  • 459
0 votes
1 answer
288 views

Web Components/Redux with .NET Core MVC viable?

I'm currenty building several new themes using NopCommerce, a .NET e-commerce platform using the MVC architecture. NopCommerce exposes a lot of services to you for communicating with the db, and is ...
user avatar
0 votes
1 answer
118 views

Managing Documentation / Source Control for a Full-Stack Application Across Multiple Repos

TL;DR I have a moderately sized/complexity web application (Angular 11) in one repo and a standalone REST API (.NET Core 3 / C#) in another repo, and am trying to figure out the most efficient way to ...
user avatar
1 vote
1 answer
46 views

Deisgn Pattern: How to map UI requests to Controllers to Services?

I'm learning about writing WebApi design patterns. I am trying to create a simple CRUD web app with ReactJS UI and C# .NET CORE webapi with sql backend. Articles show that specific Repositories are a ...
user avatar
  • 21
3 votes
1 answer
373 views

ASP.NET MVC Caching of ViewModels

My question is regarding caching and ViewModels in ASP.NET (Core) MVC. I have a service which injects a Repository<T> which is used to fetch domain models from the database. The service layer ...
user avatar
  • 139
1 vote
0 answers
44 views

How to implement timing-mechanism for fantasy draft process utilizing ASP.NET Core 3.1 SignalR

I have developed a Fantasy Draft system utilizing ASP.NET Core SignalR, along with Azure's SignalR service (for backplane/scaling stuff). Last year I utilized a poor-mans' javascript version that just ...
user avatar
  • 401
0 votes
1 answer
103 views

Should I decouple domain models from IIdentity in ASP.NET core?

I saw a lot of examples of decoupling domain models from Identity models. For my knowledge, currently IIdentity is included in standard .NET library, so is this actual now and should I follow this ...
user avatar
  • 111
0 votes
4 answers
275 views

What problems could be caused by inserting into a database on an HTTP GET?

I have code that checks if the scanned qr code exist in the database and if it exist it will insert data into another table but I did it in the HTTP GET request, is this alright to do it this way or ...
user avatar
5 votes
4 answers
334 views

How to create a modular system of multiple .NET Core applications extending a single application?

So first of all let me explain what I want to achieve: I want to create a basic .NET Core console application which is responsible for loading external extensions (more on this later on), listening ...
user avatar
0 votes
1 answer
273 views

Do I need a service layer if my current service layer looks like this? Also asking about other basic controller service-repository patterns questions

I currently have a service class RoutineService.cs that contains methods that each perform one thing, call the repository and return that exact same object. With how simple it is, is my service ...
user avatar
  • 9
-1 votes
3 answers
314 views

Preventing presentation layer from directly accessing repositories?

I'm trying to design my application in line with the "onion architecture" principles, and have something like the following: HospitalController (depends on IHospitalService) \ --- ...
user avatar
  • 1,356
0 votes
1 answer
307 views

Best practice for pulling bulk data from APIs and storing in database

I have written a small application using ASP.NET Core to create and manage collections of cards for a collectable card game. I currently have a version that successfully downloads bulk card data via ...
user avatar
0 votes
1 answer
98 views

Implementing the microservice pattern

We are developing a system that runs a certain kind of simulation for our customers: Every simulation runs on it's own server. We typically have a two digit number of simulations running. A client ...
user avatar
0 votes
1 answer
457 views

Right way of folder structure in MVC Project

I'm building a project with C# AspNet.Mvc. I'm using Entity Framework Core. It has Poco which maps in data from DB. On Mvc project itself i've got ViewModels folder where i have models topass between ...
user avatar
  • 9
0 votes
0 answers
53 views

Where to carry JWT Tokens in Requests

I have an AspNet application which I'm authenticating using a separate AspNet Core application. It returns a JWT token which is then carried in a Http Cookie. The AspNet application validates each ...
user avatar
1 vote
0 answers
142 views

How do you design a micro-app Blazor project?

I have been tasked with creating a unified UI for my current company for our Blazor Apps. We have 15 or so apps and we need to add more. Our current requirements are: UI appears the same The Menu ...
user avatar
  • 11
-4 votes
1 answer
81 views

Changing databases in general repository methods when using Dapper [closed]

I'm developing a multi-database application. There is one admin database and many customer databases which are identical in structure. I also have a generic RepositoryBase which looks like the ...
user avatar
-1 votes
1 answer
71 views

Strategy to make sure relevant cache records are expired on data update

In our database, we have around 150 different tables. However, there are a handful of them that are key, as in they get referenced pretty much everywhere. We also have quite a few reports that we pull ...
user avatar
  • 196
2 votes
1 answer
758 views

Is ASP.NET core over implementing CORS specification or is my understand of the CORS specification imcomplete?

Overview: I have performed 2 experiments to understand the implementation of asp.net core libraries with regard to the CORS specification The experiment 1 shows an web page (html) is not able to make ...
user avatar
2 votes
3 answers
321 views

Is this approach with JWT tokens wrong?

I have .NET Core WebApi application with JWT token for authorization. I also have roles and permissions. To make it more flexible for end user, I decided to make permissions like this: [Authorize(...
user avatar
  • 131
0 votes
1 answer
144 views

Designing asp.net core web api to add sub classes/specialized objects

I have not worked with EF for a while. As an exercise, I am writing a core web api that allows keeping track of a user medias. A media can be a postcard, a photo album, a recording, a book... I would ...
user avatar
  • 295
-3 votes
2 answers
116 views

Dependency access control in DI

As I'm just getting into ASP.NET Core, I'm also continuing to slowly learn about Dependency Injection and still trying to identify some value in it for our practical purposes. The point I've reached ...
user avatar
  • 189
1 vote
4 answers
657 views

Should you validate route parameters or let them fail with a 404?

So this is an example endpoint to fetch one user by its username [HttpGet("{username}")] public async Task<ActionResult<object>> GetUser([FromRoute] string username) { // ... ...
user avatar