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

Questions tagged [asp.net-core]

ASP.NET Core is a lean, composable and cross-platform framework for building web and cloud applications. It is fully open source and available on GitHub, and is currently in version 1.1.0. ASP.NET Core can be run both on .NET and .NET Core, and can be hosted on Linux and MacOS under .NET Core.

Filter by
Sorted by
Tagged with
1 vote
0 answers
62 views

Implementation of Concurrent List in .NET

I would appreciate review of this implementation of the concurrent list that is, to my knowledge, currently missing in .NET Core. Requirements Thread safe Lock free Ordered Supports get and set by ...
user avatar
  • 111
0 votes
0 answers
26 views

Resolver Factory Pattern for IoC in an Asp.Net 6 Web Server

I'm currently testing an experimental IoC pattern enabled by a factory implementation, currently implemented for use in an Asp.Net 6 web server. The pattern is intended to support lazy resolution of ...
user avatar
  • 1
0 votes
0 answers
33 views

Abstract instance creation for handler

My application uses several data sources. One is a web-service, the other uses a database context, and in some cases even files on servers have to be retrieved. I am trying to find a way to ...
user avatar
1 vote
1 answer
36 views

Configure lazy and non lazy DI for automapper

I have the following code to register the dependency injection for automapper: ...
user avatar
  • 631
1 vote
1 answer
72 views

Ensure sensitive data is removed from response

I have some DTOs returned by my API that have sensitive data fields like CreatedBy, CreatedDate, ...
user avatar
1 vote
1 answer
140 views

How to process multiple background concurrent Tasks in c#

I am trying to work out the best way to go about a task which relys on multiple long running tasks taking place. My use case is that I want to have multiple events running for set periods of time, ...
user avatar
1 vote
0 answers
43 views

MS Playwright Page Object Table Data Selector(s): Is there a simpler solution?

I'm writing some function tests and wrapping a Microsoft Playwright (it's similar to Selenium for those unfamiliar) IPage with a page object containing some helper ...
user avatar
  • 111
0 votes
0 answers
63 views

ISO Xml Serializer for .Net API Controller

I've created a pretty simple XML input formatter, that inherits from XmlSerializerInputFormatter, that is able to serialize XML input that is ISO-8859-1 encoded. I created it, so that I do not have to ...
user avatar
3 votes
2 answers
99 views

Get a list of the 25 most popular items on an E-Commerce site

I have a few lines where I am trying to get a list of the 25 most popular Items sold on an E-Commerce web site. The code works but I would like hints on how to optimize it. ...
user avatar
  • 475
-1 votes
1 answer
75 views

Basic ASP.NET Core RESTful API with Entity Framework Core

This is my first WIP backend asp.net application, which I will pair with react to create a full stack app. The thing I'm mostly worried about is model conversion to DTO and custom policy authorization,...
user avatar
4 votes
1 answer
427 views

C# Thread-safe singleton service for caching data used during lifetime of ASP.NET Core MVC application

Basic Background I have an ASP.NET Core MVC application that uses Client (e.g., "customer") information for every HTTP request. The collection of Clients, as well as their information, ...
user avatar
  • 143
2 votes
3 answers
59 views

Feedback for lambda expression to count object by DateTime.Value.Month

I want to count user registrations by month, currently the code I have works, but I want some feedback or some ideas on how to do it in a better way because I think mine looks a bit messy. Using a ...
user avatar
  • 123
1 vote
0 answers
192 views

Parallel file upload with HttpClient in API

I have created a helper service to send files from the client application to the API over HTTP using the POST method. Source project on Blazor Server Side, .NET 6, C # 10. Service features: Sending ...
user avatar
  • 111
0 votes
1 answer
96 views

Generic Base Repository implementation with Unit of Work in C#

I have seen a lot of Repository pattern implementations with Unit of Work. The simplest way of implementing this I came across is using hard-coded repos (such as this one), while the way recommended ...
user avatar
0 votes
1 answer
176 views

Custom Binance API wrapper around IHttpClientFactory

I made a custom Binance API wrapper (BinanceRestClient) which uses IHttpClientFactory in order to prevent socket exhaustion, ...
user avatar
  • 423
0 votes
0 answers
83 views

Gilded Rose with pure functions in C#

Gave myself the challenge of solving the Gilded Rose with pure functions in C#. All one-line lambdas, all static, all the time. The original kata assumed the code would mutate the given array-- I've ...
user avatar
  • 216
0 votes
0 answers
92 views

Improving the Speed of loading records into a ngx-datatable

I am using ngx-datatable to load large volumes of records. However, the larger the volume, the longer it takes. I read somewhere that you can speed it up by sorting then assigning it to the data ...
user avatar
  • 1
0 votes
1 answer
256 views

Using the repository pattern with Dapper and a single accessor object

We are using Dapper as our ORM and have chosen the repository pattern for organizing our operations. This has worked very well for us but I'd like to confirm that this configuration is capable of ...
user avatar
0 votes
1 answer
259 views

Web Api to upload excel file

I work on asp.net core 2.2 web API using C# language I need to rewrite function below with best syntax and with best practice web API below get Excel file from upload and return Excel file it working ...
user avatar
0 votes
2 answers
91 views

Finding items involving a particular category

I have a Item Service that is Called from an Asp.Net Core API Controller. The query gets all items in a particular category for display on an eCommerce web site (reactjs). The controller only returns ...
user avatar
  • 475
1 vote
2 answers
185 views

Configure service with user-related parameters in .NET Core dependency injection

I have service class which loads data from external service. This service needs API key which loads from db and unique for every user. ...
user avatar
  • 807
0 votes
1 answer
58 views

Optimizing location updates when adding a new object

I'm trying to keep a bunch of Objects called Machine in their proper order. I was wondering if it'd be possible to further optimize the function ...
user avatar
0 votes
2 answers
85 views

How to replace the given email address with a value in a given input?

I have written the below method to replace some of the email domains like @gmail.com and @yahoo.com with a given text. ...
user avatar
1 vote
0 answers
43 views

Record status of http call to show in the UI

What I am wanting to do, is record the status of a HTTP call, so that I can give the user some feedback in the UI, rather than either succeeding silently, or showing a grim error. What I have done is ...
user avatar
  • 111
4 votes
2 answers
531 views

.Net core string symmetric encryption

I need to store sensitive strings in DB, so decided to encrypt it in a DB and decrypt it at the application layer. And noticed that it is not so easy to find ready to use an example. Please check my ...
user avatar
  • 185
0 votes
2 answers
115 views

Extension method to get the Sunday date from current date based on weekOffset

I want to write an extension method for getting Sunday Date based on weekOffset and current date. For example if weekOffset value is 1 that means next week sunday date and if weekOffset is 2 that ...
user avatar
  • 1
1 vote
0 answers
40 views

Handling sessions in SignalR core

I am using .Net 5, and I am making game server using SignalR core. Ther're 2 ways to inject service to my classes. 1- Constructor injection: where I must separate functions and data, even if it's ...
user avatar
  • 11
2 votes
1 answer
258 views

Is repository pattern violated while using IQueryable outside of it?

I am writting an API backend application using .NET Core and Visual Studio. Here is the solution structure: [ProjectName] - Solution ...
user avatar
-3 votes
1 answer
83 views

Swagger doc and Entity Framework include not working [closed]

I tried to create a .Net core API using Microsoft Documentation but I ran into some issues. The app is working but only for a "single" table. The includes are empty. ...
user avatar
3 votes
2 answers
2k views

ASP.NET Core singleton with a thread-safe property that can be changed

Thanks to ASP.NET Core dependency injection, there's no need to follow the Singleton pattern; any class will do. What I want to do is to have a class that will store a value that'll be used by another ...
user avatar
  • 195
0 votes
1 answer
123 views

Is this enough for unit testing a basic controller?

My pet project, is a community driven lyrics archive, it is still a work in progress, and all code is open sourced on GitHub. I have a local git branch ...
user avatar
  • 422
1 vote
3 answers
2k views

C# Asp.net core middleware for redirecting URLs

I wrote a small middleware for redirecting between WWW URLs. The most important thing that I want to change is to make it super fast. Here's what it is doing: If the host is localhost or mywebsite.com ...
user avatar
4 votes
1 answer
664 views

A background service that will wait for items to process without busy-waiting

Problem space: I have the concept of a Job that needs to be processed. Jobs need to be processed sequentially, as one may depend on another. It's possible for a Job ...
user avatar
  • 141
2 votes
1 answer
115 views

Reviewing Basic API

I'm learning ASP.NET and I've created a few simple APIs, so I can consider myself maybe an intermediate beginner. I've decided to create a tutorial serving two purposes: to solidify what I've learned ...
user avatar
2 votes
0 answers
118 views

Handle ASP.NET WebSocket connections using TPL Dataflow

I was recently introduced to the wonders of TPL Dataflow and thought it would be a good exercise to create a wrapper class which wraps around an ASP.NET WebSocket ...
user avatar
3 votes
1 answer
65 views

Filtering database with Linq

I'm building an MVC web app with ASP.CORE 3.1 and EF connected to MSSQL. Today, finally after 3 days, I've somewhat reached a working code for filtering my view. I've got database of Date stamps (15 ...
user avatar
2 votes
2 answers
532 views

Entity Framework Core verify SaveChanges count

I am using ASP.NET Core 3.1 and have been assigned a task to verify the count of changes done using SaveChanges(). It is expected that the developer should know how ...
user avatar
6 votes
1 answer
101 views

Making an alphabatical list grouped by letters

I have a pet project (open source on GitHub) that I built as a learning exercise. It is a lyrics web application built in .NET Core MVC. On the artists page of the site (view on mobile size viewport, ...
user avatar
  • 422
2 votes
0 answers
120 views

ASP.NET Core 3.1 Multi-tenant with separate database

I am following this sample by Gunnar Peipman to create a multi-tenant architecture in my ASP.NET Core 3.1 application. It is working as expected up to the point shown in the sample. ...
user avatar
3 votes
1 answer
162 views

Abstracted email sender with content providers

I've created an email sender with providers for the email content, that will be changed based on the email type. I need some help to enhance it. These two models are used to send ...
user avatar
  • 151
2 votes
1 answer
712 views

Entity Framework Core DbFunction for square root

I'm porting my site over from .NET Framework / MVC 5 / EF6 to .NET Core 3.1 MVC / EF Core. MSSQL Server for the database. EF6 has SqlFunctions of which one method ...
user avatar
  • 33
9 votes
2 answers
414 views

News site in ASP.NET Core

I am new to ASP.NET Core 3.1 with no background of MVC. I am just moving from Web Forms to ASP.NET Core. I asked elsewhere and I got the following comments regarding my code. The code is working fine ...
user avatar
  • 193
1 vote
1 answer
184 views

Validating a name with C#, ASP.NET Core 3.1 and Regex

This class validates that a name contains only letters and optionally spaces, hyphens and apostrophes. ...
user avatar
  • 107
3 votes
2 answers
2k views

Validating a date with C# and ASP.NET Core 3.1

I have a simple class to ensure the date entered into a form is a valid date. Where can I improve it, have I missed anything? ...
user avatar
  • 107
4 votes
2 answers
131 views

pagination in entity framework and refactoring

I have an api end point which returns the paginated result, the corresponding code for that is as below: ...
user avatar
  • 41
2 votes
1 answer
91 views

Testing an action returns a View with a ViewModel using xUnit and Moq

This is my first test, I think it's testing what I need it to test but wanted to get some feedback. I wanted to test to make sure the controller action returns a view with a certain ViewModel. The ...
user avatar
  • 107
2 votes
0 answers
2k views

Uploading files through streaming with SignalR

I want to upload files from my Javascript client to my WebAPI. With this I want to have a progress bar. My Idea was to cut the files up in chunks and then stream them via SingalR since we are using ...
user avatar
-1 votes
1 answer
307 views

ASP.Net Core API JsonPatchDocument

Hi I am creating a website for my chiropractor and I am creating the API for data access. I am creating a HttpPatch Method and want to know if this is the right approach so would be grateful if you ...
user avatar
3 votes
1 answer
1k views

ASP.NEt Core thread safe global variable

I have a .net core razor app that has a special use case where I need to have a global counter that will be incremented by every request, and yet it should remain thread-safe. Also at web application ...
user avatar
6 votes
2 answers
2k views

ASP.NET Core 3.1 AddHttpClient call that includes a call to the database

So, I have an ASP.NET Core 3.1 web site that makes occasional calls to a vendor's RESTful API. I use the HttpClient class to perform these calls. Currently, the ...
user avatar