<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ASP.NET MVC on InternetException</title><link>https://internetexception.com/tags/asp.net-mvc/</link><description>Recent content in ASP.NET MVC on InternetException</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 27 Feb 2023 14:04:19 +0100</lastBuildDate><atom:link href="https://internetexception.com/tags/asp.net-mvc/index.xml" rel="self" type="application/rss+xml"/><item><title>ASP.NET Core controller level exception handling</title><link>https://internetexception.com/2022/10/25/asp-net-core-controller-level-exception-handling/</link><pubDate>Tue, 25 Oct 2022 15:53:52 +0200</pubDate><guid>https://internetexception.com/2022/10/25/asp-net-core-controller-level-exception-handling/</guid><description>&lt;p&gt;To handle exceptions on Controller/Action level Exception Filters are used.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;[TypeFilter(typeof(SampleExceptionFilter))]&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ExceptionController&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Exception Filters are implemented using &lt;code&gt;IExceptionFilter&lt;/code&gt; with &lt;code&gt;OnExcetion&lt;/code&gt; method override to handle exceptions.&lt;/p&gt;&#10;&lt;p&gt;Exception Filters can be applied to Controller and Action level.&lt;/p&gt;&#10;&lt;p&gt;Further read:&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-7.0#exception-filters" target="_blank" rel="noopener noreferrer"&gt;https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-7.0#exception-filters&lt;/a&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.filters.iexceptionfilter?view=aspnetcore-7.0" target="_blank" rel="noopener noreferrer"&gt;https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.filters.iexceptionfilter?view=aspnetcore-7.0&lt;/a&gt;&#10;&lt;/p&gt;</description></item><item><title>What ASP.NET Middleware can do?</title><link>https://internetexception.com/2022/10/25/what-asp-net-middleware-can-do/</link><pubDate>Tue, 25 Oct 2022 15:45:12 +0200</pubDate><guid>https://internetexception.com/2022/10/25/what-asp-net-middleware-can-do/</guid><description>&lt;p&gt;Pretty much everything. Default ASP.NET Core request handling pipeline is consisting of bunch of middlewares:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-6.0" target="_blank" rel="noopener noreferrer"&gt;Authentication&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.builder.authorizationappbuilderextensions.useauthorization" target="_blank" rel="noopener noreferrer"&gt;Authorization&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-6.0" target="_blank" rel="noopener noreferrer"&gt;CORS&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-logging/?view=aspnetcore-6.0" target="_blank" rel="noopener noreferrer"&gt;HTTP Logging&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/mvc/overview?view=aspnetcore-6.0" target="_blank" rel="noopener noreferrer"&gt;MVC&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-6.0" target="_blank" rel="noopener noreferrer"&gt;Static Files&lt;/a&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;other&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Whole list of built-in middlewares can be found here:&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-7.0#built-in-middleware" target="_blank" rel="noopener noreferrer"&gt;https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-7.0#built-in-middleware&lt;/a&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;There is possibility to write custom middleware too.&lt;/p&gt;</description></item><item><title>WebSocket libraries comparison</title><link>https://internetexception.com/2014/02/21/websocket-libraries-comparison/</link><pubDate>Fri, 21 Feb 2014 14:38:00 +0100</pubDate><guid>https://internetexception.com/2014/02/21/websocket-libraries-comparison/</guid><description>&lt;p&gt;Web project often requires to push data to clients as fast as possible, whenever it is necessary without waiting for client request. It is perfect for website with real time communication between users, like with online communicators for example. Or document collaboration tools. Or maybe system status updates on long running calculation/tasks performed by server. In every case two way communication mechanism is ideal.&lt;/p&gt;</description></item></channel></rss>