Customizing ASP.NET Core Part 9: ActionFilter

This post is a little late this time. My initial plan was to throw out two posts of this series per week, but this didn’t work out since there are sometimes some more family and work tasks to do than expected.
Anyway, we keep on customizing on the controller level in this, the ninth, post of this blog series. I’ll have a look into ActionFilters and how to create your own ActionFilter to keep your Actions small and readable.

Link: https://dzone.com/articles/customizing-aspnet-core-part-09-actionfilter

When to Use ”Var” as a Type

It has been quite a long time since var was introduced, yet it remains a topic of debate among .NET developers. Everyone has a different understanding about when to use “var" as a type. A couple of days ago, I was also a part of one such discussion, and so through this article, I would like to share my understanding of the topic.
Readability
Every developer has all the rights to use var as and when they like, it’s just a matter of one’s choice. However, one must keep in mind that every line of code should be self-explanatory and developer-readable. Let’s have a look at the below code:

Link: https://dzone.com/articles/when-to-use-quotvarquot-as-a-type?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

Customizing ASP.NET Core Part 07: OutputFormatter

In this seventh post, I want to write about, how to send your Data in different formats and types to the client. By default the ASP.NET Core Web API sends the data as JSON, but there are some more ways to send the data.
The Series Topics

Customizing ASP.NET Core Part 1: Logging
Customizing ASP.NET Core Part 2: Configuration
Customizing ASP.NET Core Part 3: Dependency Injection
Customizing ASP.NET Core Part 4: HTTPS
Customizing ASP.NET Core Part 5: HostedServices
Customizing ASP.NET Core Part 6: Middleswares
Customizing ASP.NET Core Part 7: OutputFormatter – This article
Customizing ASP.NET Core Part 8: ModelBinder
Customizing ASP.NET Core Part 9: ActionFilter
Customizing ASP.NET Core Part 10: TagHelpers

About OutputFormatters
OutputFormatters are classes that turn your data into a different format to send them through HTTP to the clients. Web API uses a default OutputFormatter to turn objects into JSON, which is the default format to send data in a structured way. Other built-in formatters are an XML formatter and a plain text formatter.

Link: https://dzone.com/articles/customizing-aspnet-core-part-07-outputformatter

Top 10 Debugging Tips for .NET

The best-laid plans of mice and men still go off the rails sometimes. Even when you’ve been rigorous and put unit tests in place, there are times when you’ll want to jump in and debug an application or a unit test. In this article, we’ll take a look at 10 debugging tips for .NET.
1. Setting Breakpoints
A breakpoint is one of the fundamental units of debugging. It is a hint to the debugging environment that it should stop the execution of the application at a certain point. If you’re using the full Visual Studio IDE, then adding a breakpoint is simple. Click in the gutter next to the line of code on which you want to halt execution.

Link: https://dzone.com/articles/top-10-debugging-tips-for-net?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

Inject DateTime.Now to Aid Unit Tests

If you have logic that relies on the current system date, it’s often difficult to see how to unit test it. But by injecting a function that returns DateTime.Now we can stub the current date to be anything we want it to be.
Let’s look at an example. Here we have a simple service that creates a new user instance and saves it in a database:

Link: https://dzone.com/articles/inject-datetimenow-to-aid-unit-tests?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

Full Stack Development From Client-Side JavaScript [No Node.js]

In case you think the above header sounds like an oxymoron or some sort of black magic, think again. With Lizzie, you can (at least in theory) create your entire business logic in JavaScript, in your browser, submit your Lizzie code to the server for evaluation (securely), and have it return JSON back to your client.
For the record, this assumes you’ve previously created generic “hooks" in C#, allowing your Lizzie code to do something useful, since, out of the box, Lizzie can barely do anything at all, besides from creating lists, dictionaries, do basic math, and some simple string manipulation. However, if you create generic methods for retrieving data from your database, etc., creating your business logic in JavaScript as Lizzie code, and transmitting this code to your server for evaluation, is actually a breeze. This in turns creates a much more dynamic server-side API, allowing you to (after a while) do anything you want from JavaScript, without having to code in (any) server-side language at all. At least that’s how the theory goes. To understand what I am talking about, picture the following code.

Link: https://dzone.com/articles/full-stack-development-from-client-side-javascript?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

Return 0 Value From C# Entry Point Method Using Parent and Child Programs

Hello everyone, as we know that in C# apps (both Console and Win) Entry Point Method refers to the Main() of a program. When the application is started, the Main method is the first method that is invoked. This Main() does have a return type of “int” and much of the time we noticed that the return value for this Main() seems to 0. So let’s understand the behind the scenes of this return value.
Background
In general, our assumption is (after a Google search) a return of 0 in Main() refers to the status code of the application such as, “Exited Successfully,” or if it’s 1. then it exited with some errors. But, these 0/1 values are user-defined.

Link: https://dzone.com/articles/getting-return-0-value-from-c-entry-point-method-u?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

Parsing in C#: All the Tools and Libraries You Can Use (Part 3)

Welcome back! If you missed the first two parts, you can check them out here: Part 1; Part 2.
Parser Combinators
Parser combinators allow you to create a parser simply with C# code, by combining different pattern matching functions that are equivalent to grammar rules. They are generally considered to be best suited for simpler parsing needs. Given that they are just C# libraries, you can easily introduce them into your project: you do not need any specific generation step and you can write all of your code in your favorite editor. Their main advantage is the possibility of being integrated in your traditional workflow and IDE.

Link: https://dzone.com/articles/parsing-in-c-all-the-tools-and-libraries-you-can-u-2?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

A Breakdown of Blazor Project Types

We discuss the three project types available with Blazor 0.5.1, get an understanding of what scenarios to apply them to, and explore what to expect from each.
Blazor is a single-page web application (SPA) framework built on .NET that runs in the browser with Mono’s WebAssembly run-time or server-side via SignalR. Blazor features a component architecture, routing, a virtual DOM, and a JavaScript Interoperability (interop) API. Currently, Blazor is in an experimental state which allows for rapid development, iterations, and, as implied, experimentation.a

Link: https://dzone.com/articles/a-breakdown-of-blazor-project-types?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev