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
2 votes
0 answers
27 views

POST-Redirect-GET in ASP.NET Core MVC preserving user input and validation messages (v2)

I have a multi-page form to submit and update an application for an event built using ASP.NET Core MVC. Each page of the form consists of the display information managed by the organizer (1) and the ...
  • 51
1 vote
1 answer
56 views

POST-Redirect-GET in ASP.NET Core MVC preserving user input and validation messages

I have a multi-page form to submit and update an application for an event built using ASP.NET Core MVC. Each page of the form consists of the display information managed by the organizer (1) and the ...
  • 51
2 votes
1 answer
27 views

Azure AD Role Based Authorization : Allow specific roles for all GET methods and another set of roles for POSTS

There is a need to authorize the Users based on their Roles, particularly a set of roles that should allow all GET operations and a second set that should allow all POST operations. Eg: All Get ...
1 vote
1 answer
55 views

Azure DevOps Git: Fork into another Repo using Azure DevOps REST API

In my Azure DevOps Project, I have a Git repository that I would like to copy to another Azure DevOps Project. In other words, I should be able to copy the original repo into other Azure DevOps ...
3 votes
1 answer
70 views

Export and import work items from Azure DevOps

I'm working on an application that exports and imports work items from Azure DevOps. To import work items into Azure DevOps, I have written the following code. Would you be able to review and make ...
3 votes
2 answers
80 views

Looking to interact with a DbContext entity through a different service

I have 2 Data Models let's call them Lecture/Teacher that have a one-to-many relationship, in a service method I need to get a teacherId given a certain condition ...
  • 43
0 votes
0 answers
49 views

Is there a better way to update the related data in Entity framework core 6.0.7?

Role Entity has multiple SkillRoleRequirement, Education & Experience ...
1 vote
1 answer
173 views

.Net Core 6.0 : Entity Framework - Either Or / Neither Nor / Both in Where clause

I am building a .Net Core 6.0 application that uses Entity Framework. I have situation where I need to apply the filter(Where clause) based on two properties (eg: Guid? skillType, string skillName). ...
0 votes
0 answers
70 views

BaseController with Generic Entity and Model

I created a controller with generic TEntity and TModel so that i will not have to repeat common actions like save/delete for each entity. I just want to ask if this is a good or a bad practice? ...
0 votes
1 answer
104 views

ASP.NET Core Authorization handler that allows request from private IP ranges

In a docker compose solution, there are multiple ASP.NET Core projects. Each of them provide a service. Some of them can be accessed from internet (with REST APIs), some of them are for local docker ...
  • 23
0 votes
1 answer
176 views

Is it optimal way to filter records from table using Entity Framework?

I have the SQL Products table migrated from MongoDb and I use ASP Core + MediatR. The filtering data comes from frontend ...
0 votes
1 answer
88 views

ASP.NET Core simple DB cleaner background service

In an application there is a table for one-time-passwords (OTP) which will be sent to users via SMS. These OTPs are needed for a maximum of two hours in order to detect abusing behaviours. A simple DB ...
  • 23
2 votes
1 answer
219 views

ASP.NET Core background logger queue with dynamic workers

In a docker compose environment there are several apps that communicate with each other. One of these apps is a logger (a centralized logger). Every part of the system that needs to log something, ...
  • 23
1 vote
1 answer
65 views

Asp.Net Core CacheKey Management

I created cache management structure for Asp.Net Core and Redis. But i dont know is this best practices or bad. My Github Repo First one is Store my entity keys class is ...
0 votes
0 answers
114 views

ASP.NET Core 6 background DB logger

In an application, many actions need to be logged in the database. but this logging process should not slow down the request. So they should be done in an asynchronous queue or something. This is my ...
1 vote
0 answers
585 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 ...
  • 111
0 votes
0 answers
74 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 ...
  • 21
0 votes
0 answers
39 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 ...
1 vote
2 answers
162 views

Configure lazy and non lazy DI for automapper

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

Ensure sensitive data is removed from response

I have some DTOs returned by my API that have sensitive data fields like CreatedBy, CreatedDate, ...
1 vote
1 answer
1k 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, ...
1 vote
0 answers
182 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 ...
  • 111
0 votes
0 answers
138 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 ...
3 votes
2 answers
104 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. ...
  • 481
-1 votes
1 answer
80 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,...
4 votes
1 answer
1k 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, ...
  • 143
2 votes
3 answers
99 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 ...
  • 123
1 vote
0 answers
440 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 ...
  • 111
0 votes
1 answer
283 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 ...
0 votes
1 answer
298 views

Custom Binance API wrapper around IHttpClientFactory

I made a custom Binance API wrapper (BinanceRestClient) which uses IHttpClientFactory in order to prevent socket exhaustion, ...
  • 579
0 votes
0 answers
193 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 ...
  • 1
0 votes
1 answer
821 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 ...
0 votes
1 answer
1k 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 ...
0 votes
2 answers
96 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 ...
  • 481
1 vote
2 answers
794 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. ...
  • 839
0 votes
1 answer
60 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 ...
0 votes
2 answers
120 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. ...
1 vote
0 answers
44 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 ...
  • 111
4 votes
2 answers
833 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 ...
  • 185
0 votes
2 answers
129 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 ...
  • 1
1 vote
0 answers
89 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 ...
  • 11
2 votes
1 answer
591 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 ...
-3 votes
1 answer
128 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. ...
3 votes
2 answers
3k 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 ...
  • 195
0 votes
1 answer
175 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 ...
  • 424
1 vote
3 answers
4k 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 ...
4 votes
1 answer
1k 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 ...
  • 141
2 votes
1 answer
117 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 ...
2 votes
0 answers
151 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 ...
3 votes
1 answer
70 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 ...