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
33 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
136 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
54 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
0 votes
1 answer
140 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
179 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
666 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
580 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
  • 719
2 votes
1 answer
155 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 ...
Cenk's user avatar
  • 37
2 votes
0 answers
149 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
  • 96
2 votes
1 answer
281 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
  • 96
2 votes
1 answer
119 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
107 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
214 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
92 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
0 votes
0 answers
155 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 ...
Mugil Karthikeyan's user avatar
2 votes
1 answer
1k 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
0 votes
0 answers
229 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? ...
John Louie Dela Cruz's user avatar
0 votes
1 answer
712 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
  • 123
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
201 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
  • 123
2 votes
1 answer
568 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
  • 123
1 vote
1 answer
265 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
0 votes
0 answers
276 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 ...
Parsa99's user avatar
1 vote
0 answers
2k 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
  • 111
0 votes
0 answers
295 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 ...
RTD's user avatar
  • 121
1 vote
2 answers
666 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
  • 631
2 votes
1 answer
719 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
3k 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
418 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
-1 votes
1 answer
100 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
255 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
865 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
437 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
509 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
  • 719
0 votes
0 answers
438 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 ...
KP257's user avatar
  • 1
1 vote
1 answer
2k 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
369 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
3k 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
100 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
2k 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
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 ...
RDAxRoadkill's user avatar
0 votes
2 answers
436 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
47 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
422 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
198 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
1k 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
215 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