Skip to main content
24 votes
Accepted

What data should a repository return

And knowing (correct me if I'm wrong) that a repository shouldn't return a DTO Theoretically, every layer (= project in your solution) should have its own DTO objects. In that sense, your repositories ...
Flater's user avatar
  • 59.5k
13 votes

Can a caller abort an execution of code invoked by HTTP request?

HTTP doesn't work like that. The client sends a request, then the server sends a response back. No other communication occurs. Well, the server can send 1xx informational responses before the main ...
amon's user avatar
  • 136k
12 votes
Accepted

why controller lifetime is transient by default in asp.net core?

There's a number of advantages to transient controllers. I cannot tell you whether any of them were the reason they were done that way - speculating about the intent of designers does not make a good ...
Sebastian Redl's user avatar
11 votes

Is it a bad practice to use Singleton for DI in Asp.net rather than Scoped, Transient whenever possible?

Is it a bad practice to use X whenever possible? Yes. It is bad practice to turn off your brain and lean on absolutes. It's far better to understand why. So lets step back from that framework and try ...
candied_orange's user avatar
10 votes
Accepted

Application_Start() vs ApplicationStart()

This is an event handler, in addition to being a method. The convention for naming event handlers is EventOrigin_EventName(...). Event origin can be a name of an instance (camel case), or a name of a ...
Nick Alexeev's user avatar
  • 2,532
10 votes
Accepted

Why is it bad to map between a Model and a ViewModel in an extension method

It isn't how extension methods are supposed to be used, it is not in the spirit of extension methods. I'm going to hard counter that notion, because it is exactly the spirit of extension methods. ...
Flater's user avatar
  • 59.5k
10 votes

Is it a bad practice to use Singleton for DI in Asp.net rather than Scoped, Transient whenever possible?

Firstly, you are confusing singletons provided by a DI container with the "Gang of Four" singleton pattern. The latter is a glorified global variable and thus a complete anti-pattern and ...
David Arno's user avatar
  • 39.6k
8 votes

Colleague wants web apps to behave like Windows desktop programs

User expectations should be taken into account when developing software but users are bad sources of UX/UI specifications. You need to have (or be) a UX/UI designer to design a UI that fulfills the ...
Hans-Martin Mosner's user avatar
8 votes

Is it a bad practice to use Singleton for DI in Asp.net rather than Scoped, Transient whenever possible?

Before you change whether a service is Transient, Scoped, or Singleton, do make sure you are not introducing bugs. When something is designed to be thrown away quickly, there might be assumptions ...
Berin Loritsch's user avatar
7 votes

Is CQRS/MediatR worth it when developing an ASP.NET application?

I highly recommend you view Jimmy Bogard's NDC presentation on his approach to modelling http requests https://www.youtube.com/watch?v=SUiWfhAhgQw You will then get a clear idea of what Mediatr is ...
DavidRogersDev's user avatar
7 votes
Accepted

At what point does a microservices architecture become "worth it" vs. a monolithic ASP.NET web application?

As I see it, the size of the application doesn't really have much to do with the microservices pattern. After all, you can always choose to build a few large monoliths or to build a monolith out of ...
Michael's user avatar
  • 6,487
7 votes
Accepted

Is there a library or algorithm I can use to solve this type of problem efficiently in C# (.NET Core 3.0)?

Unfortunately, this is known as a Set Cover problem, and this type of problem is known to be NP-Complete. You can find approximations to the correct answer in polynomial time, but a guaranteed correct ...
Beska's user avatar
  • 195
6 votes

Is CQRS/MediatR worth it when developing an ASP.NET application?

Many people (I did it too) confuse pattern with a library. CQRS is a pattern but MediatR is a library that you can use to implement that pattern You can use CQRS without MediatR or any in-process ...
Konrad's user avatar
  • 1,569
6 votes
Accepted

How to unit test public method which internally calls many internal or private methods which are already individually unit tested

how do we test the public service methods in such a way that we don't have to duplicate the code/effort that we have already spent in testing the internal/private/helper methods? Don't unit test your ...
Philip Kendall's user avatar
5 votes

Is it possible to cache data on a REST service that returns paginated data?

Isn't it possible to simply cache the thousands of records somewhere to avoid calling the database each time Yes, but it is the exact opposite of being stateless, which REST is. You're trying to go ...
Flater's user avatar
  • 59.5k
5 votes
Accepted

Is .NET ASP MVC core suitable for rapid web development?

Yes .Net Core although still very new, is suitable for rapid web development. Caveat #1 : Asp.Net MVC/WebApi is the more mature technology. You may find it more compatible if you are doing lower ...
Ewan's user avatar
  • 84.6k
5 votes
Accepted

Reasons why the ASP.NET Web API Controller cache ignores dynamic assemblies

This problem originates in the .NET Framework itself, not in ASP.NET Web API. If you look at the code for DefaultHttpControllerTypeResolver.cs line 80, you'll see that it contains the following ...
Robert Harvey's user avatar
5 votes

ASP.NET MVC Caching of ViewModels

It doesn't make sense to cache the ViewModel ViewModel + View = HTML. So if your view model hasn't changed then the HTML hasn't changed. You can just return the cached page. Cache the models, because ...
Ewan's user avatar
  • 84.6k
4 votes

How to handle large switch statement running several different commands?

Since you have tagged this question with C#, I'll offer the language-specific answer to your question. C# and the BCL offer a built-in version of the command pattern: a dictionary of delegates. Rather ...
David Arno's user avatar
  • 39.6k
4 votes

How to impersonate user in web app?

Update to your update. So I am looking at building something into my web page that allows the business user to pick an end user from a list of names, then pass that login name along to the web ...
Flater's user avatar
  • 59.5k
4 votes
Accepted

3 layer architecture In DI based software

The entry point of the application (the UI project) must setup the DI container, providing implementations of all the dependencies. That's why it must have direct connection (reference) to all the ...
Rumen Georgiev's user avatar
4 votes

Is it good practice to save an entire ViewModel in Session (C# ASP.NET MVC)

Putting all of your view model data in the session essentially creates global variables. If you have two different view models setting the same session key one will overwrite the other — and you ...
Greg Burghardt's user avatar
4 votes

Why do backend web frameworks use "MVC" when they have no persistent UI to update?

Again, I had it wrong originally, updated, and still might contain stuff wrong, If someone can write a proper answer I'm all for it. Okay, so I had it wrong. Updated: THE MVC The Model is the ...
mishan's user avatar
  • 211
4 votes

Storing uploaded images in Azure

Definitly recommend Azure Blob Storage. It is the intended way. It’s also VERY cheap. Blobs in SQL have no advantage except a dependency less. But now you lose a lot of other free stuff like caching, ...
Dirk Boer's user avatar
  • 454
4 votes

Gradual upgrade of an inherited .NET Framework project

You will want to target .NET 8, which is the latest version. Using .NET 6 is not recommended because it is out of support (see Microsoft .NET and .NET Core Lifetime Policy). First, assess the project ...
Greg Burghardt's user avatar
4 votes
Accepted

Planning Dynamic Patient Charts with Version Control and Historical Accuracy - Temporal Versioning or JSON

I think you are likely to have a much better result with the JSON document option or something similar. The main reason being this: When notes and forms are updated, I need to ensure that providers ...
JimmyJames's user avatar
  • 31.1k
3 votes
Accepted

Microservices - External access tokens stored in identity service, calendar service, or both?

You should create an id of your own for the user - and use that to request tokens from the ID server. If you store those tokens in multiple services, you'll have multiple to update on expirations and ...
Jimmy Hoffa's user avatar
  • 16.2k
3 votes

What are the differences between .NET Framework, ASP.NET, .NET Core, ASP.NET Core and .NET Standard?

You can use same .Net standard dll in the projects of type .Net Core and .Net Framework. .NET Standard is the best way to add cross-platform support to a .NET library. .NET Standard is a specification ...
cansu's user avatar
  • 169
3 votes

What does Identity Server offer that ASP.NET Core Identity does not

Identity Server allows you to issue access tokens for APIs. In my experience, I've only seen it used when the application requires custom OAuth 2.0 authentication that cannot be provided by the ...
neverseenjack's user avatar
3 votes
Accepted

Dealing with settings that will change on a per-environment basis?

@amon's answer is spot on. The best way to deal with this in a tech stack agnostic way would be with build scripts, etc. to create the files you need at build time. However, since you are working in ...
Becuzz's user avatar
  • 4,865

Only top scored, non community-wiki answers of a minimum length are eligible