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
1 answer
128 views

Refactor to get one more layer of abstraction for less repeated code

I might add more methods, but currently I have this design: So connectionString comes from IOptions pattern. Then for each ...
LonelySemicolon's user avatar
-3 votes
1 answer
66 views

Best practice code for payment integration [closed]

I am new to coding, and I am doing my best to write efficient and robust code. I am also trying to incorporate design patterns into my code. Could you please take a look at my repository and let me ...
Thomas Charles's user avatar
1 vote
0 answers
93 views

Asp.net Core Razor Pages Complex Databinding Select List to Entity List

I'm new to Razor pages. I would like to bind a <select> list to an object's property that is a list of another object (Report.EventyTypes). Consider the ...
yougotiger's user avatar
2 votes
2 answers
377 views

Thread safe accessing memory cache using semaphore

I have a Web API and for some requests we are sending requests to a third party API that requires request authentication. It's a simple bearer token, which I'd like to reuse across requests, because ...
Prolog's user avatar
  • 263
1 vote
0 answers
143 views

Razor Pages PageModel Initialization When Sharing Data Between OnGet and OnPost

I'm trying to find the best way to initialize some PageModel, avoiding repetition and preventing nullable reference types warnings. Please see the below example. Is ...
user276847's user avatar
-1 votes
1 answer
198 views

Optimizing LINQ Query on C# Web API

Can someone help me optimize this code especially the LINQ query. It takes 8-12 seconds just to return a response when I'm calling the endpoint. Its super slow, and my whole endpoint call is taking ...
Kraust123's user avatar
1 vote
4 answers
199 views

C# decomposition and refactoring of a very long Web Data Scraping Function with multiple different tasks using a Clean Architecture Pattern

I inherited a very long and messy C# function with a task to make it more readable and Clean Architecture Pattern friendly. The primary goal of a function is to send an API request to an endpoint and ...
Vedran Knezevic's user avatar
1 vote
0 answers
947 views

Extend the login timeout in a ASP NET 7 application

My ASP Core web application was recently upgraded from NET6 to NET7. Almost zero problems except one, which still puzzles me. With the "old" NET6 version, once an user log then app in (...
Mario Vernari's user avatar
2 votes
1 answer
873 views

Serilog logging extension methods

I've been using this extension in almost all of my projects. What's your opinion? Do you think there is something else to add or to be improved? The idea is to ignore all default ASP.NET messages that ...
nop's user avatar
  • 739
2 votes
1 answer
171 views

Retrieving large batches of online game codes?

In my current solution, a user triggers my web API from a web application of mine first, then my web API calls a 3rd party web service, and the results/codes are displayed on the web application. In ...
raysefo's user avatar
  • 197
2 votes
0 answers
174 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 ...
pikachu's user avatar
  • 106
2 votes
1 answer
417 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 ...
pikachu's user avatar
  • 106
2 votes
1 answer
149 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 ...
Mugil Karthikeyan's user avatar
1 vote
1 answer
134 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 ...
Mugil Karthikeyan's user avatar
3 votes
1 answer
258 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 ...
Mugil Karthikeyan's user avatar
3 votes
2 answers
93 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 ...
Isu's user avatar
  • 143
2 votes
1 answer
2k 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). ...
Mugil Karthikeyan's user avatar
1 vote
1 answer
882 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 ...
Parsa99's user avatar
  • 133
0 votes
1 answer
1k 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 ...
user2771704's user avatar
0 votes
1 answer
228 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 ...
Parsa99's user avatar
  • 133
2 votes
1 answer
809 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, ...
Parsa99's user avatar
  • 133
1 vote
1 answer
393 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 ...
filiphasan's user avatar
3 votes
1 answer
3k 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 ...
Anonymous's user avatar
  • 131
1 vote
2 answers
831 views

Configure lazy and non lazy DI for automapper

I have the following code to register the dependency injection for automapper: ...
Pete's user avatar
  • 641
2 votes
1 answer
998 views

Ensure sensitive data is removed from response

I have some DTOs returned by my API that have sensitive data fields like CreatedBy, CreatedDate, ...
sebascomeau's user avatar
1 vote
1 answer
4k 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, ...
user3284707's user avatar
1 vote
0 answers
487 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 ...
agartee's user avatar
  • 111
3 votes
2 answers
109 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. ...
Randy's user avatar
  • 487
0 votes
1 answer
119 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,...
Damian Nizio's user avatar
4 votes
1 answer
3k 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, ...
elmer007's user avatar
  • 143
2 votes
3 answers
292 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 ...
Jacob's user avatar
  • 123
1 vote
0 answers
957 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 ...
abberdeen's user avatar
  • 111
0 votes
1 answer
479 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 ...
oneManArmin's user avatar
0 votes
1 answer
577 views

Custom Binance API wrapper around IHttpClientFactory

I made a custom Binance API wrapper (BinanceRestClient) which uses IHttpClientFactory in order to prevent socket exhaustion, ...
nop's user avatar
  • 739
1 vote
1 answer
3k 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 ...
Adam Chubbuck's user avatar
0 votes
2 answers
390 views

Strategy Design Pattern in ASP.Net Core MVC Project

I tried to make a calculator using the Strategy pattern in ASP.Net Core MVC (following an example from the Internet) Please review my code and tell me what could be wrong and how to make it better? My ...
WarmingZ's user avatar
0 votes
1 answer
4k 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 ...
ahmed barbary's user avatar
0 votes
2 answers
105 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 ...
Randy's user avatar
  • 487
1 vote
2 answers
3k 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. ...
sDima's user avatar
  • 849
0 votes
1 answer
61 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 ...
RDAxRoadkill's user avatar
0 votes
2 answers
556 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. ...
Vivek Nuna's user avatar
1 vote
0 answers
48 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 ...
Keith's user avatar
  • 111
4 votes
2 answers
1k 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 ...
Ssss's user avatar
  • 185
0 votes
2 answers
608 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 ...
Coder's user avatar
  • 1
1 vote
0 answers
236 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 ...
Adam Q's user avatar
  • 11
2 votes
1 answer
2k 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 ...
user238115's user avatar
-3 votes
1 answer
237 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. ...
AnthonyDa's user avatar
3 votes
2 answers
6k 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 ...
Léster's user avatar
  • 205
0 votes
1 answer
266 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 ...
J86's user avatar
  • 414
1 vote
3 answers
7k 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 ...
Nikas music and gaming's user avatar