InternetException

ASP.NET

ASP.NET · 6 posts (all tags)

Kestrel

· 36 words · ~1 min read · in .NET, interview

#ASP.NET

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

· 43 words · ~1 min read · updated · in .NET, interview

#ASP.NET MVC #ASP.NET

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: https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-7.0#exception-filters https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.filters.iexceptionfilter?view=aspnetcore-7.0

ASP.NET Core global exception handling

· 14 words · ~1 min read · in .NET, interview

#ASP.NET

To add global exception handling in ASP.NET Core just use configuration method: app.UseExceptionHandler https://learn.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-6.0#exception-handler-lambda

What ASP.NET Middleware can do?

· 42 words · ~1 min read · updated · in .NET, interview

#ASP.NET MVC #ASP.NET

Pretty much everything. Default ASP.NET Core request handling pipeline is consisting of bunch of middlewares: Authentication Authorization CORS HTTP Logging MVC Static Files other Whole list of built-in middlewares can be found here: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-7.0#built-in-middleware There is possibility to write custom middleware too.

Middleware in OWIN

· 141 words · ~1 min read · in .NET, interview

#delegates #async #ASP.NET

There are 2 ways of writing OWIN middleware in ASP.NET Core.

  • Pure OWIN - usefull if you want to integrate with OWIN compatible module but not written in C#
  • ASP.NET Core OWIN middleware

ASP.NET Core Middleware:

This type of middleware can be:

  • delegate of Func<HttpContext, Func<Task>, Task>
  • class with IMiddleware imlementation
app.Use(async (context, next) =>
{
    // Do work that can write to the Response.
    await next.Invoke();
    // Do logging or other work that doesn't write to the Response.
});

Pure OWIN Middleware:

This rather would be used to integrate with OWIN middlewares written in different language, so that ASP.NET Core implementation directly is not possible.

Read the whole thing →