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
12
votes
1answer
6k views

Using IServiceScopeFactory without implementing the Service Locator Pattern

I want to use IServiceScopeFactory in a way, which is not the Service Locator anti-pattern. Therefore I thought about making a generic one, which supports ...
9
votes
2answers
371 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 ...
8
votes
2answers
119 views

Wordpress RSS Parser

Follow Up to my earlier question. This is an RSS Parser intended only to parse the feed Wordpress provides (and even then, only what I actually want to display on my website). ...
8
votes
1answer
122 views

Shopping cart purchase method in service layer

The following is a class in the service layer of an ASP.NET Core web application, which currently contains a single method: PurchaseCart. The intention is that an ID is passed in to a "shopping cart" ...
7
votes
2answers
1k views

A controller on a .net core API

BACKGROUND I am working on a .Net Core API to drive a lyrics application. Users can sign up, submit artists & lyrics, and earn kudos / XP points in the process. Basically a community-driven ...
7
votes
2answers
14k views

Adding extension methods to IServiceCollection in ASP.NET Core

I have the following extension method to add themes support to my application: ...
7
votes
1answer
516 views

Computing a hash value of a file

I am trying to see if there is a more efficient way of creating a hash of a file of unknown size (could be gb). My code below works fine but I am sure there is a more efficient way of achieving this. ...
7
votes
2answers
9k views

ASP.NET Core singleton acting as an HttpClient provider

I have created an ASP.NET Core singleton service class to act as an HttpClient provider after reading that reusing an instance of HttpClient is encouraged. However, I also want to be sure that the <...
7
votes
1answer
554 views

Playing Checkers

Continuing with my web-based checkers game, this question is about the actual playing system. I'll ask for a review on my UI system in the next post. First, my BoardController.cs. Note that I have ...
6
votes
2answers
1k views

.NET Core MVC - Future proof Hashing of passwords

I have written a Helper for Hashing passwords in .NET Core. It should have the following constraints: Future proof (It should be possible to upgrade the Hashing Engine to support Legacy and New ...
6
votes
2answers
140 views

Middleware for sending PartialViews via email

After all partial views are rendered and all styles are inlined my RESTful service is sending them via email. I implemented this feature with a MailerMiddleware. ...
6
votes
2answers
68 views

Getting Authors and Books from a simple database

I have simple database with many to many relations. I wrote simple method GetAuthors() ...
6
votes
1answer
199 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 <...
5
votes
3answers
1k views

Length units converter

I am creating a very small application to demonstrate solid principles and also a brief implementation of a builder pattern, does anyone have any feedback as to how this could be improved or how it ...
5
votes
3answers
15k views

Return XML file from Web API

I have a HttpGet method which returns XML file: ...
5
votes
2answers
90 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 ...
5
votes
2answers
153 views

Filter Producs by any property

I have Products table which looks like this: I have some data in this table and I want to filter it depending on this columns (Filtering with columns type of string isn't problem). For this I have ...
5
votes
1answer
5k views

asp.net core - get User at Service Layer

I use ASP.NET Core 2.1 and would like to fetch User at a service level. I've seen examples when HttpContextAccessor gets ...
5
votes
1answer
3k views

Safely executing background tasks in parallel in ASP.NET Core

Context and initial idea I'm trying to teach myself the CQRS and Event Sourcing patterns by developing a simple ASP.NET Core application, loosely following Greg Young's example CQRS implementation on ...
5
votes
2answers
10k views

Proper way to work with stored procedures in Entity Framework Core

I need to work with stored procedures, with the help of Entity Framework Core. This is my function: ...
5
votes
0answers
108 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-...
5
votes
0answers
493 views

Auto register Func<T> for .net core dependecy injection

The default .net core dependency injection doesn't support building Func<> for injection automatically, see question. I wrote an extension method to go find all the Func in register types ...
5
votes
0answers
1k views

OAuth2 login for ASP.NET Core without local accounts

I am using OAuth2 for users to sign in with their Google Account and authenticate Google API requests. I have not used the built-in ASP.NET Identity provider because this requires an app database of ...
4
votes
2answers
2k views

Generate secure URL safe token

...
4
votes
1answer
153 views

User controller for a .net core WebAPI dating app

I have this user controller that follows the repository pattern. It works perfect, but is it easy to understand? Is this good quality work? ...
4
votes
2answers
4k views

Insert array items into jQuery / JavaScript variable

This code exists in my view; it makes use of a model passed through from the controller. ...
4
votes
1answer
137 views

Unit testing extension method adding view location expander

Introduction I'm writing unit tests for an extension method I wrote. Its only purpose it is to wrap startup logic which extends ViewLocationExpanders list by an ...
4
votes
2answers
66 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: ...
4
votes
1answer
101 views

Asp.net networking/restclient layer

I have been working on creating maintainable networking layer for our Asp.Net Core Web Api project. Right now I have created Generic methods for Get, Post, Put like this. ...
4
votes
2answers
3k views

Load ASP.NET Core plugins and their dependencies

I'd like one of my RESTful services to support plugins. Currently it uses references hardwired at compile-time. The Application Parts seem to be THE solution so I gave it a try and created a small ...
4
votes
1answer
2k views

Linked List implementation Entity Framework Core

I am trying to create a data model where there are Document entities, which need to be in a defined order to each other. Think of an article that has sections which ...
4
votes
0answers
63 views

MVC Controller Error & Exception Handling .NET Core

I'm putting together a basic web app in .NET core 2.1 MVC to try and better understand how it works. Currently I'm working on returning validation to the UI. Once I have this working I then want to ...
4
votes
0answers
10k views

Logging into Database with ASP.NET Core

In the Startup.cs of my ASP.NET Core application I want to configure the LoggingFactory so that it logs into the database. ...
3
votes
1answer
598 views

XML design for parsing in C# [closed]

I am trying to design XML with configuration info so I can parse it into this code: ...
3
votes
1answer
1k views

Notification system

I would like to implement a mail notification system Notification.cs ...
3
votes
2answers
89 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? ...
3
votes
2answers
579 views

Implementing unified API data flow in ASP.NET Core

I have the API project on ASP.NET Core, and it's quite annoying always write methods like this: ...
3
votes
2answers
154 views

Submitting a form

I am using ASP.NET core entity framework. I am using an input submit button to call a method that has a variable attached to it. I am wondering if there is a way to improve my code. Here is my ...
3
votes
2answers
140 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
1answer
83 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
1answer
1k views

Enum synced with Database

Our database has several tables that have a value that can be one of 4 things, so we made these columns instead have an id column with a foreign key to an enum table with an id and a value column to ...
3
votes
1answer
47 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 ...
3
votes
1answer
61 views

Sub-Middleware like options builder for an Asp.Net Core Middleware

Building upon a recent question I answered here Simple middleware pipeline builder (similar to asp.net-core) I came across a cross site question Stackoverflow: Adding middleware in Carter framework ...
3
votes
1answer
99 views

Deserialize with LINQ query code in PageModel or PageView

Today I do something like this, where I get, select and sort some data and pass it on to the view (which loads a partial view) as a list of custom objects Page model ...
3
votes
1answer
70 views

Logic is stored in Components that receive input data and update output data via Observables

I have C# ASP.Net Core Webapi application that makes some calculations for physical models. I have this project class: ...
3
votes
1answer
2k views

ASP.NET Core Request / Response logging middleware

I am looking for feedbacks about my ASP.NET Core Request / Response logging middleware, in particular in ways to lower the memory footprint and string allocations: ...
3
votes
1answer
104 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 ...
3
votes
1answer
1k views

WebSocket API that connects to ASP.NET Core Backend

I'm writing this API that connects to my ASP.NET Core Cloud App and listens for potential Database changes from my CMS. The code runs and works fine but I'm not sure if my code is considered "good" ...
3
votes
1answer
409 views

Handling signout flow

There is backend which connects with IdentityServer using WsFederation. The backend is .NET Core project where there is a ...
3
votes
0answers
124 views

ASP.NET Core 3.1 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 ...