Skip to main content

Questions tagged [asp.net]

ASP.NET is a web application framework developed by Microsoft to allow programmers to build dynamic web sites and web applications.

Filter by
Sorted by
Tagged with
0 votes
0 answers
37 views

Custom ASP.NET Core CookieAuthenticationHandler

I wrote a CustomCookieAuthenticationHandler because I don't like the way CookieAuthenticationHandler.HandleForbiddenAsync() ...
iKingNinja's user avatar
6 votes
3 answers
361 views

Implementing Generic Enumeration Classes in Domain Layer

I'm developing an ASP.NET Core application using .NET 8, following the Onion Architecture. In our domain model, we use Enumeration classes instead of traditional ...
James Black's user avatar
1 vote
1 answer
32 views

Map domain entities using AutoMapper.ProjectTo and clean architecture approach

We have a mid-size project. Two projects in solution, API and Domain. Domain contains services with business logic. We don't use repositories. Just call DbContext directly from services (that's fine ...
user1614543's user avatar
3 votes
1 answer
92 views

How to avoid null Values in a .NET 6+ ASP.NET project [closed]

I'm currently exploring multiple options to get rid of null values in my .net web api applications. Let's say, that we have the following Project: ...
szuuuken's user avatar
  • 131
3 votes
2 answers
71 views

Validating a web crawlers page visits with a decorator

I am writing a crawler that is going to end up in production and I was trying to come up with a way to validate its page visits. It scrapes asp.net pages so each scraping process involves a few ...
Gustavo Costa's user avatar
2 votes
1 answer
55 views

Convention based OpenApi schema generation for dotnet and NSwag

So I am getting tired from adding the same [ProducesResponseType] attribute on my WebAPI controller methods over and over, and I thought there must be an easier, ...
Marc Wittke's user avatar
1 vote
1 answer
59 views

Insert huge data from csv file in .Net framework 4.7.2

I need to insert about 500k - 1 million data lines from a CSV file. The time of getting the reports list and insert to database by using SqlBulkCopy is very good (...
HaNgocHieu's user avatar
0 votes
1 answer
96 views

logging in using cookie authentication/authorization in asp.net C#

How safe is Cookie based Authentication/Authorization in ASP.NET C#? Take a look at the example below, don't worry about password hashing, All this code does is that it takes a username and a password ...
Newbie's user avatar
  • 23
2 votes
1 answer
240 views

Building ASP.Net control from JSON Data

I am working project where I need to build ASP.net control base on JSON data. I am using this method below to get all the data into class. I as using FirstOrDefault ...
Jefferson's user avatar
  • 353
2 votes
1 answer
1k views

C# lock on string value

Our codebase is full of locks such as: lock("Something." + var) { .... } This causes issues due to strings not meant to be used in locks in this way. ...
Tom Gullen's user avatar
1 vote
1 answer
67 views

Handling resource authorization in a service

Problem: My application is built upon clean architecture. I want to create a new instance of a class in my lower layer, but the class itself resides in an upper layer. The upper layer can depend on ...
Damian Nizio's user avatar
0 votes
1 answer
122 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
1 vote
1 answer
5k views

Beginner CRUD Console Application

I wrote this basic CRUD app + simple report so I could practice talking to a db directly. I purposefully avoided repository pattern and Entity Framework and only used a library to show the coming data ...
Pablo Aguirre de Souza's user avatar
2 votes
2 answers
199 views

Best Practice for Button Event Handler

I have a button btnSearch and the event handler btnSearch_Click inside my asp.net web application, using web forms. (certain ...
Austin's user avatar
  • 177
1 vote
1 answer
167 views

Parse meter readings from CSV file

I have a class representing meter readings: ...
user16405900's user avatar
1 vote
1 answer
461 views

Asp.net core response caching with custom key values

I'm trying to build a response cache with custom key values (from headers and cookies). Here's the code I have so far, and it kinda works, but I need a second opinion or suggestions for improvements. ...
Robert's user avatar
  • 113
0 votes
2 answers
592 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
4 votes
1 answer
2k views

.Net 5.0 Get User Email From Claims

From searching online I have identified two ways to get the user email, but I don't know if either has pro's/con's beyond Option.1 being a larger number of lines of code? Option.1 I have a dedicated <...
DMur's user avatar
  • 143
2 votes
1 answer
96 views

Asp.Net overall design pattern integrating REST, dependency injection, and Hosted Services (See full project at Github)

I'm new to C#, and want to conform as much as possible to good design patterns. This code is the beginning of a Microservice, running as Asp.Net. It is based on a Microsoft tutorial doing similar work....
RightmireM's user avatar
0 votes
1 answer
399 views

Is this correct way to setup DB Infrastructure with repository pattern and Dapper

So, I am using Repository pattern with Dapper and ADO.NET. I have my based DB infrastructure setup as follows: ...
Rahul Sharma's user avatar
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
2 votes
1 answer
124 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 ...
Pablo Aguirre de Souza's user avatar
1 vote
2 answers
1k views

ASP.NET Core async iactionresult

I am new to async methods and am kinda confused how async is working so what i want for you to do is review this code and tell me does implementing async like this is meaningless ...
Aleksa Ristic's user avatar
7 votes
3 answers
2k views

C# Am I using proper SOLID principles?

I am currently practising using the SOLID principles in C#/.NET I have made a little example, but i am not sure if i have followed it correct. Its a simple example where i have an API controller that ...
Martin C's user avatar
  • 130
3 votes
0 answers
2k views

Validating the model outside of the controller in ASP.NET

I wasn't quite sure whether I should do it this way or create a validation service and inject it, but this works: Controller: ...
MF1010's user avatar
  • 107
9 votes
2 answers
4k views

C# Convert BLOB to jpg, resize, then back to BLOB

I am trying to convert a BLOB that is stored in a database to a JPG and then I need to display it on an ...
Jamie's user avatar
  • 193
1 vote
1 answer
1k 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. ...
MF1010's user avatar
  • 107
4 votes
2 answers
6k 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? ...
MF1010's user avatar
  • 107
7 votes
2 answers
4k 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 ...
EJoshuaS - Stand with Ukraine's user avatar
1 vote
1 answer
93 views

Decoupling of validation and data access in ASP.NET

I've been asigned to a project no dev has touched in a long time. It's an ASP.NET MVC 4 application. It appeared to be well coded, but had no testing and the database migration folder is not present. ...
Peter's user avatar
  • 165
3 votes
0 answers
39 views

Prettified GridView: is this JS code concise?

I been writing code for my company for years and there is never any constructive criticism for what I do. I am the only developer here and I would appreciate your opinion on this web page I made. It ...
John Henderson's user avatar
1 vote
1 answer
1k views

ASP.NET EF seed one to many relation

I am creating a simple model relation in ASP.Net core. My model relations are like this: A user can have many posts A post can have many comments A user can have many comments Now I am trying to ...
Bikram's user avatar
  • 113
-2 votes
1 answer
136 views

Is it good practice to use try catch only for a part of the code [closed]

When I submit the form, I need to validate the input data from an HTML form field, which comes from the user who submitted the data. So inside the Page_Load event, ...
Adam's user avatar
  • 97
3 votes
2 answers
206 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 ...
Denis's user avatar
  • 8,508
1 vote
2 answers
72 views

Collecting 3 years of data and building a string

I am collecting 3 years of data and building a string that will be used with an ASP Literal control. The method GetListOfMeetingBygroupId takes in a ...
Jefferson's user avatar
  • 353
3 votes
0 answers
5k 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 ...
Bryder's user avatar
  • 139
2 votes
1 answer
1k views

Extension method for getting custom Principal Claim

I'm writing extension methods to shorten the code required to get custom Claims from an IPrincipal. I have two general forms for ...
Michael Brandon Morris's user avatar
3 votes
1 answer
118 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? ...
MM1010's user avatar
  • 133
0 votes
1 answer
143 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#: ...
user1206480's user avatar
2 votes
1 answer
164 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 ...
Sam's user avatar
  • 127
3 votes
1 answer
110 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: ...
rst's user avatar
  • 207
2 votes
0 answers
1k views

Ninject binding for Dbcontext

I have an asp.net web API and I am using EF6 to connect to a third party rest API which sells online game codes. We made a deal with the company so clients have to call my rest API in order to get the ...
Cenk's user avatar
  • 21
1 vote
1 answer
50 views

Update any controls' Text for the specified language [closed]

I would like to optimize the below code The only difference is the datatypes RadioButton, Label, and Button. Outside the method I have an loop that iterates over all the controls in the aspx-page. I ...
Jon's user avatar
  • 119
2 votes
1 answer
594 views

Encrypts using AES GCM for data with limited visibility and long rest

This is the third iteration of my venture on creating an encryption/decryption solution. I asked a question here, which led to this question here, which led to this answer here, which led me to ...
user1447679's user avatar
1 vote
1 answer
890 views

Encrypts using AES with random initialization vector meant for data with limited visibility and then long rest

I've done some research, reviewed countless SO questions that appeared similar, leading me to endless rabbit holes. My solution is working, but I don't like it. I want to create a random IV for AES ...
user1447679's user avatar
0 votes
2 answers
76 views

The function to convert an object to a URL string

There is a function to convert object to the GET parameters for the ASP.Net controller. Is it possible to minimize the redundancy of the code, but not to the detriment of its readability? ...
XelaNimed's user avatar
  • 103
0 votes
1 answer
37 views

StringBuilder returing Web script

Task : With the page_type and currentpage param I made this code that returns the web script of the web page with active class on the current page through aspx behind code. Is there a better and a ...
BongJae Jeong's user avatar
0 votes
1 answer
67 views

Check if mail contains a single page pdf and transfer to other folders

This code checks if a mail message contains a single page PDF attachment. If yes, it adds it to a processed list else rejected list. If mail can be processed, then it saves the attachment into a file....
Gauravsa's user avatar
  • 131
2 votes
1 answer
637 views

Displaying all application errors in a view

I'm learning ASP.NET Core with MVC pattern and I didn't find anything useful related to this argument. Actually I'm looking ...
Charanoglu's user avatar
3 votes
2 answers
220 views

Subscribe to Event form one service to another

In my architecture I have service layer, and for my question two relevant classes in this layer: UserManagementService EmailSenderService In first service there is method: ...
hyperN's user avatar
  • 231

1
2 3 4 5
9