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
0
votes
0answers
12 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 ...
-1
votes
0answers
31 views

Asp.net Rest Api higher requests [closed]

I would like to build a Asp.net (with net5) rest api service, and i would like to know if i'm on right way. This service will cache values from other service Y for X minutes, if client will ask data ...
2
votes
1answer
61 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 ...
-1
votes
0answers
54 views

How to use Dependency Injection properly in asp.net core?

I have a legacy Asp.net Core 3.1 application which uses Kestrel server and all our GET and <...
-3
votes
1answer
37 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. ...
1
vote
2answers
74 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 ...
0
votes
1answer
84 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 ...
2
votes
3answers
101 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
1answer
74 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 ...
2
votes
1answer
107 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
0answers
49 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
1answer
59 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 ...
2
votes
2answers
123 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 ...
6
votes
1answer
92 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, ...
2
votes
0answers
81 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. ...
3
votes
1answer
151 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 ...
2
votes
1answer
237 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 ...
9
votes
2answers
396 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 ...
1
vote
1answer
57 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. ...
3
votes
2answers
121 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? ...
4
votes
2answers
80 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: ...
3
votes
1answer
52 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 ...
2
votes
0answers
425 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 ...
-1
votes
1answer
138 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 ...
3
votes
1answer
536 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 ...
6
votes
2answers
610 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 ...
2
votes
2answers
934 views

Best way to replace Urls in .Net application

I have an application developed in ASP.NET Core C#, where according to a configuration it must replace certain urls of a text when an http request is made and the text must be returned as soon as ...
1
vote
1answer
76 views

Three-way join in Entity Framework Core to retrieve all roles that a user has

I'm very new to Entity Framework Core, so I'm concerned about whether I've done this query in the most efficient way possible. The database I'm querying looks like this: Basically, ...
1
vote
0answers
36 views

Handle login method with external users and LDAP users

I'm working with a ASP.NET Core (v2.2) Web Api project and implemented some APIs. However, I'm facing performance issues, hence trying to optimizing the code. Here is the login API code. ...
5
votes
2answers
257 views

ASP.NET Core Web API + Pure DI

I was playing around with ASP.NET Core 3.1 and tried to implement Dependency Injection flavor called Pure DI, i.e. without dependency container (even the built in one) to instantiate Controllers. You ...
1
vote
0answers
820 views

Accurately measure ASP.NET Core 3.x actions execution times (Web API project)?

I want to be able to log the time spent by a certain Web API action in an ASP.NET Core 3.x application. This is a very old question from ASP.NET which relies on global action filters, but in ASP.NET ...
2
votes
1answer
81 views

Handling external API calls status code in my application

I have a Web API application in .NET Core 3.1. In a controller I have a GET action that must return a JSON object with a name and a description. In order to retrieve the correct description I need to ...
3
votes
1answer
68 views

Basic Unit Test of Application Service, setup and cleanup methods

I'm not experienced with testing, therefore I'd like you to look at my code proposal of unit test. My solution has following projects Tests\Application.Tests Application Domain Infrastructure Web ...
6
votes
1answer
353 views

c# Factory Pattern Generic Exception Handler using dot net core

My task was to create exception handler on some system that has multiple types of database and big business behavior. At first, I had done a switch/case that handled the exceptions by type using the <...
1
vote
1answer
61 views

A Class to Supply an Open Database Connection during the life of a Web Request

For some database requests, I like to use raw ADO.NET. In the context of a web request, I have created a class which provides an open IDbConnection object. I use ...
2
votes
0answers
124 views

Web API get data with many optional parameter in .NET Core

I would like to do a refactoring of web API implemented in .NET Core. The Goal is to simplify ...
3
votes
2answers
144 views

Asynchronous catalog with paging and partial views

I'm trying out .net core with mvc in a personal project, the latest functionality I've added was a project catalog, primarily ajax based, it's displaying a list of projects fetched from the database ...
3
votes
0answers
2k views

Hosted service for queuing and running tasks in parallel in ASP.NET Core

I am attempting to construct a background service for an IIS-hosted ASP.NET Core project that basically queues tasks and runs them, and I decided to go with the ...
5
votes
0answers
122 views

Using ClientFactory-pattern with Dependency Injection

I initially posted this on Stackoverflow but was recommended to try here instead. I'm looking for feedback on why the implementation of my ClientFactory is probably bad, from a Dependency Injection-...
3
votes
1answer
89 views

Refactoring code to implement clean code using repositories

I've been refactoring code today, try to implement a clean code setup using repositories. Is this on track? Can any improvements be made? ...
3
votes
0answers
81 views

Flashcard Website

In my endeavor to learn Angular, I've created a flashcard site with an F#/Mongo backend. As I'm new to Angular, I'm going to post everything; any and all feedback is welcome. First, some pictures of ...
0
votes
1answer
202 views

Mixing Async and Sync in same HTTP request ASP.NET Core C#

Is it bad practice to mix async and sync call in same ASP.NET core API call? For example, in following code method CropBlackBroderOfAnImageAsync is an async method....
3
votes
0answers
106 views

ASP .NET Core DI: Dependency on single implementation of multiple registrations of service type

Problem I have a DI scenario where I have multiple classes that implement a common interface (IModelService). I'm using a generic framework class (...
2
votes
1answer
361 views

HttpClient Wrapper for standardized API communication

This is our company's first attempt at an API and a mobile friendly web project, primarily we are desktop developers. We are using Identity Server 4 for serving up tokens and authentication, we have ...
0
votes
1answer
89 views

Asp.net middleware [closed]

This code is asp.net core middleware written in f# and called from c# for a blazor server-side app. How can this be made more efficient if any in regards to the async code. F#: ...
1
vote
1answer
34 views

Calculate sum of an attribute across multiple repositories

I have multiple repositories that contain userId, paidDate and amount attributes like ...
-1
votes
1answer
58 views

Reduce CPU utilization in constant pinging to API and saving data in to database service [closed]

I have this hosted service which grabs the data from API every second and process the data and save it into the database. I have similar 3 more hosted services which run at the same time. Because of ...
2
votes
0answers
104 views

ASP.Net Core WebAPI Authorization Policy for User or Admin [closed]

I have a controller that returns data about users. I want to set the authorization such that an admin can access this controller and retrieve data for any user, and a non-admin user can access the ...
2
votes
1answer
91 views

Hosted service which perform CRUD operations in high update environment

I have this hosted services which garbs the data from the API and save it in the database. But before saving it checks if the data already exists in the DB if not it creates the new row and if it ...
2
votes
1answer
44 views

Posting images from request to Azure blob

I have base Controller for Attachments, here is code of it In this controller, I pass data from the request and return URL of the posted object. ...