In the previous part (Python Bottle Guide (Translation) Part 3 - Routing Requests), we discussed the main aspects related to routing requests. In this part, we will discuss the aspects related to the transmitted content. S...
In the previous part (Python Bottle Guide (Translation) Part 2 - Hello World) we created a simple Web application with one single route, here is the part of the code with routing from the 'Hello World' example: @route('/hello') def hello…
Example: using System; using Newtonsoft.Json; using System.Xml.Linq; namespace ConsoleAppTest { class Program { static void Main(string[] args) { string xml = @"<response><user>Roman</user><status>Active</status></response>"; XDocument doc =…
Example of a method that makes a request data to the server and receives a response res at the specified address url : public static string ServerRequest(string data, string url) { string res = ""; try { // To check SSL and just went and took what they give p...
Starting from C# 7 version, the language has a feature that allows declaring a local variable that references an array element or a field in an object: int[] simpleArray = {0, 1, 2, 3, 4, 5, 6, 7, 8}; ref int simpleElementRef = ref simpleArra…
Example of adding logging to a .NET Core Web application based on NLog. Initially, add the NLog.Web.AspNetCore package via Nuget. Then add a nlog.config file to the project root with the following content: <?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="true">
<targets>
<target name="file" xsi:type="FileTarget" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message}" />
</targets>
</nlog>
Good news, now you can implement SWITCH in a new way. In C# 8, switch expressions are introduced, which implement a shorter syntax for returning a value. Here is the syntax of the SWITCH expression example:
Sometimes you have to deal with converting a sentence in Russian to a Russian text but in Latin (translit), for example, when sending SMS to reduce costs - because Latin usually fits more and is cheaper. Or when bringing links to a website in a convenient form without Cyrillic, or simply for sending information to solve problems with coding in this exotic way, there are many options where this may be useful.
Simple example of a class with a method for getting a square preview image in .NET Core, using the SixLabors.ImageSharp library. Example: using SixLabors.ImageSharp; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Pixe…
Currently, the company Microsoft is devoting more and more resources to .NET Core, which is truly cross-platform and universal. Therefore, it would not be superfluous to record the process of setting up access to a site written in .NET Core in Ubuntu Linux using Apache.