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
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.
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.
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:
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.
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.
Welcome back! If you missed the first two parts, you can check them out here: Part 1; Part 2.
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.
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.
Welcome back! If you missed Part 1, you can check it out here.
The basic workflow of a parser generator tool is quite simple: you write a grammar that defines the language, or document, and you run the tool to generate a parser usable from your C# code.
This is a series similar to a previous one we wrote, Parsing in Java.
If you need to parse a language or document from C#, there are fundamentally three ways to solve the problem:
In this article, we will learn how to use C# Interactive in Visual Studio. The C# Interactive window has been a part of Visual Studio since the Visual Studio 2015 update 1 release. In this article, I am using Visual Studio 2017 for demonstration purposes. C# Interactive is a REPL Editor, i.e. Read-Evaluate-Print-Loop with an advanced editor. With the C# Interactive window, we can test our code snippet without compiling or running the complete code. Let’s Begin: