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 ...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
asp.net × 633c# × 204
asp.net-mvc × 85
.net × 70
architecture × 57
web-development × 53
mvc × 43
design-patterns × 37
webforms × 33
design × 30
web-api × 29
entity-framework × 29
javascript × 23
web-applications × 23
sql-server × 22
web-services × 20
asp.net-core × 20
iis × 19
asp.net-mvc-web-api × 18
php × 16
security × 16
jquery × 15
sql × 13
authentication × 13
database × 12