IDisposable
- Asynchronous programming in .NET
- Type system
- Garbage Collector
- Records
- Compilation and runtime
- Reflection
- Pattern matching
- EntityFramework
- Linq
- Expression Trees
- ASP.NET
- Open – for you to consider
- new .NET features
- new C# features
Equals and GetHashCode
Custom implementation is usually only necessary if default, reference equality is not enough. In example:
- entities value based equality
- value equality of deserialized objects
- custom comparisons based on other criterias
public class ImaginaryNumber : IEquatable<ImaginaryNumber> { public double RealNumber { get; set; } public double ImaginaryUnit { get; set; } public override bool Equals(object obj) { return Equals(obj as ImaginaryNumber); } public bool Equals(ImaginaryNumber other) { return other != null && RealNumber == other.RealNumber && ImaginaryUnit == other.ImaginaryUnit; } public override int GetHashCode() { return HashCode.Combine(RealNumber, ImaginaryUnit); } }
Difference between Controller and ControllerBase
Controller
type inherits fromControllerBase
and have Views supportControllerBase
type is better suited for APIs
Further read:
https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-6.0
Kestrel
- default application server for .net
- cross platform
- best performance and memory utilization
- may not have some advanced features of HTTP.sys on Windows
- may be used with proxy server or as internet facing server
Further read:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-6.0
ASP.NET Core controller level exception handling
To handle exceptions on Controller/Action level Exception Filters are used.
[TypeFilter(typeof(SampleExceptionFilter))] public class ExceptionController : Controller
Exception Filters are implemented using IExceptionFilter
with OnExcetion
method override to handle exceptions.
Exception Filters can be applied to Controller and Action level.
Further read: