[Nasıl Yapılır] C# ile NTier Mimari Örneği – Unit Of Work – Repository Pattern – Validation – Testing

image1 677x400 - [Nasıl Yapılır] C# ile NTier Mimari Örneği - Unit Of Work - Repository Pattern - Validation - Testing

Merhaba hanımefendiler, beyefendiler.

Uzun zamandır bu video serisini çekmek istiyordum ve sonunda bitirdim, Youtube sayfasında yayına aldım.

Dilim döndüğünce, N Katmanlı Mimaride bir uygulama geliştirmeyi basit düzeyde anlatmaya çalıştım. Bu süreçte iş katmanı, Unit Of Work tasarım deseni, Repository tasarım deseni geliştirdim ve bol örnekli test yazdım. Testler özellikle çok iyi oldu.

Sürç-ü lisan ettiysek şimdiden affola.

Youtube Link: https://www.youtube.com/playlist?list=PLojQVfYvlEpec2hnuVZEe84I7ijBolYVU

Github Link: https://github.com/eniskurtayyilmaz/NTier

image1 - [Nasıl Yapılır] C# ile NTier Mimari Örneği - Unit Of Work - Repository Pattern - Validation - Testing

Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor

image 5 722x400 - Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor

Bir .NET Core Web API projesi geliştiriyorum. (Dotnet Version: 2.2.401)

Karar verdim. Eğer Web API içerisinde bir sorun olursa, ziyaretçilere “Web Api’de ne oldu” diye gösterecektim ve bunu Response Body içerisinde yapacaktım. Ama önce, genel bir Global Exception middleware’ini yazmam gerekecekti.

Tamam, bunu yaptım ve onlara response body içerisinde gösterdim.

Fakat bazen bu doğru yol değildir eğer bir Web API projesi geliştiriyorsanız. Response Headers içerisine de ekleyebilirsiniz. (Bence yapmalısınız)

Aynı mesajı, response headers içerisine de customize edecek şekilde yaptım ve ne oldu dersiniz? Crash!!!

Neden oldu dersiniz? Headers içerisinde ASCII olmayan karakter kabûl etmiyormuş. (Teşekkürler stackflowover.com)

Mesajım “Login olamıyor mk.” idi 🙂

image - Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor
[Web API]
image 1 - Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor
[Global Exception için Middleware- Startup.cs]
image 4 - Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor
[Global Exception için customize headers tanımları- HttpResponse_AddApplicationError_Extensions.cs]

Postman uygulaması ile (Postman çok önemli bir tool) denediğimde, body ve headers kısımları boş geliyordu.

image 2 1024x631 - Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor
[WEB API’den gelen Response Body Bilgisi – Postman]
image 3 1024x599 - Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor
[WEB API’den gelen Response Headers Bilgisi – Postman]

Sonunda çözümü buldum. Body kısmı çalışıyordu, headers kısmı çalışmıyordu çünkü ASCII karakter olmayanları kabul etmiyordu. Ben de headers kısmını base64’e çevirmeye karar verdim.

Çalışıyor.

image 5 - Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor
[Converting to base64 – Extensions.cs]
image 6 1024x531 - Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor
[WEB API’den gelen Response Body Bilgisi – Postman]
image 7 1024x531 - Çözüldü: .NET Core Response Headers İçerisinde ASCII Olmayan Karakterlere İzin Vermiyor
[WEB API’den gelen Response Headers Bilgisi – Postman]

Tamamdır çalışıyor ve biraz kod yazmam lazım! Görüşürüz.

Solved: .NET Core Doesn’t Pass Non ASCII Characters In Response Headers

image 5 722x400 - Solved: .NET Core Doesn't Pass Non ASCII Characters In Response Headers

I’m coding a new project in .NET Core Web API. (Dotnet Version: 2.2.401)

I decided that If there is something wrong in the Web API, I can show them (the visitors) “What happened in Web API” in response body. But first, I have to set up global exception things in my project.

Ok.. I did it! I gave them a message in response body.

In sometimes this is not good way If you creating a web api project. You can add to response headers. (I think you must do it)

So, I tried to add same message in response headers and It happened.. Crash..

Because, my error message was containing non ascii characters. (Thanks stackflowover.com)

My message was “Login olamıyor mk.”

image - Solved: .NET Core Doesn't Pass Non ASCII Characters In Response Headers
[Code Snippet from Web API]
image 1 - Solved: .NET Core Doesn't Pass Non ASCII Characters In Response Headers
[Middleware for Global Exception- Startup.cs]
image 4 - Solved: .NET Core Doesn't Pass Non ASCII Characters In Response Headers
[Customize Headers for global exception – HttpResponse_AddApplicationError_Extensions.cs]

When I using Postman app (Postman is a tool used to send requests), It seems like there is an issue. Because body and header is empty.

image 2 1024x631 - Solved: .NET Core Doesn't Pass Non ASCII Characters In Response Headers
[Response Body from WEB API – Postman]
image 3 1024x599 - Solved: .NET Core Doesn't Pass Non ASCII Characters In Response Headers
[Response Headers form WEB API – Postman]

Finally, I found the solution. The response body was working, headers not working because of non ascii characters issue. I decided that the message of customize header must be base64 in response header.

It works!

image 5 - Solved: .NET Core Doesn't Pass Non ASCII Characters In Response Headers
[Converting to base64 – Extensions.cs]
image 6 1024x531 - Solved: .NET Core Doesn't Pass Non ASCII Characters In Response Headers
[Response Headers from WEB API – Postman]
image 7 1024x531 - Solved: .NET Core Doesn't Pass Non ASCII Characters In Response Headers
[Response Body from WEB API – Postman]

Ok guys, It’s working and I have to write some code!

Solved: VS2017 Running Debug Selected Tests Does Not Open The Debugger

I had an issue that VS2017 Running Debug Selected Tests Does Not Open The Debugger.

Last night, I was working on a project. I finished the some tasks, the some tests and I pushed to GitLab all of the projects, using GIT.

Today, I went to office. I pulled all of the projects from source control to my computer. I clicked Restored NuGet Packages on VS Solution Explorer, But I didn’t run all of the tests. I didn’t get neither green check or red error, and It seems like unselected. I tried to debug but It didn’t work! I was getting the following errors:

Image 005 1024x785 - Solved: VS2017 Running Debug Selected Tests Does Not Open The Debugger
VS2017 running debug selected tests does not open the debugger

'testhost.x86.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\testhost.x86.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.CoreUtilities.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.PlatformAbstractions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.CrossPlatEngine.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.CommunicationUtilities.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.TestPlatform.Common.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Newtonsoft.Json.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Extensions\Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Extensions\Microsoft.VisualStudio.TestTools.CppUnitTestFramework.ComInterfaces.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.Composition\v4.0_4.0.0.0__b77a5c561934e089\System.ComponentModel.Composition.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IO\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.IO.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\System.Collections.Immutable.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Reflection\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Reflection.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IO.FileSystem\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.IO.FileSystem.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IO.MemoryMappedFiles\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.IO.MemoryMappedFiles.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Handles\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.Handles.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Reflection.Extensions\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Reflection.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Threading\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Text.Encoding\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Text.Encoding.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Extensions\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x3ca0 has exited with code 0 (0x0).
The program '[13572] testhost.x86.exe: Program Trace' has exited with code 0 (0x0).
The program '[13572] testhost.x86.exe' has exited with code 0 (0x0).

So, I thought that “Maybe VS 2017 crashed”. I restarted VS 2017, I tried again and failed again.

At least, I decided that “Clean Solution” and It worked!

Image 006 1024x720 - Solved: VS2017 Running Debug Selected Tests Does Not Open The Debugger

What is JSON And How To Using It In C#

Merhabalar.

Geçen hafta C# Corner adresinde yayınlanmış olan İngilizce makalemin orijinal kopyasını kendi web adresimde de paylaşmaya karar verdim. 11.04.2016 10:47 itibari ile 2.9k okunmasıyla beraber, aldığım geri bildirimler ve gelen mesajlar ile “Bir sonraki makale ne olsun?” sorusuna da cevap arıyorum. Herkese iyi kodlamalar.

Working with JSON in C#
(What is JSON And How to Using It In C#)

This article will cover the following:

  • What is JSON
  • How to create JSON string in C#
  • How to read JSON string in C#

 

What is JSON

JSON (JavaScript Object Notation) is standard designed for human-readable data interchange. I think the thing of ‘human-readable’ for developers. JSON works with a tree structure and it looks like a XML. It’s shorter and It’s very easy for using. If you have already experience with XML, you will certainly learn easily.

JSON vs. XML

\wp content\uploads\2016\csharpcorner\picture1 - What is JSON And How To Using It In C#

Let’s examine this expression { “name”: “Stephen Cousins” }

  1. If you’re using JSON, you must put your expression in “{ }”
  2. “name” is the key.
  3. “Stephen Cousins” is a value of “name” key

 

JSON has the logic like { “key”: “value” } statement.
And also JSON has the array.

Let’s take another expression and examine that:

"students": [
{ "name": "Stephen Cousins" },
{ "name": "Austin A. Newton" },
{ "name": "Adam Wilhite" },
{ "name": "Enis Kurtay YILMAZ" }
]
  1. “students” is the key.
  2. “[“ and “]” square brackets are array statement. It means there is the array between “[“ and “]” in brackets.
  3. All of statements in square brackets are value of “students” key.
  4. As you see there are four arrays in square brackets and it represents four student names.

 

How to create JSON string in C#

Please create your new console project from Visual Studio

File -> New-> Project->Console Application (.NET Framework 3.5)

If you want to create or read a JSON string, you need a JSON Serialize or Deserialize.

So, please open your Solution Explorer in Visual Studio, right click on References, click “Manage NuGet Packages”

\wp content\uploads\2016\csharpcorner\picture2 - What is JSON And How To Using It In C#

Please search “Newtonsoft.JSON” on Nuget Package Manager and install it.

\wp content\uploads\2016\csharpcorner\picture3 - What is JSON And How To Using It In C#

Please add “using Newtonsoft.Json;” statement. If you forget to add this statement, you can’t serialize any JSON strings.

Example JSON:

{
"universities": {
"university": "South Carolina State University",
"students": [
{ "name": "Stephen Cousins" },
{ "name": "Austin A. Newton" },
{ "name": "Adam Wilhite" },
{ "name": "Enis Kurtay YILMAZ"}
]
}
}

Now, you need to create class for example JSON. If you want to create easily, you can use that web site -> www.jsonutils.com

\wp content\uploads\2016\csharpcorner\picture4 - What is JSON And How To Using It In C#

Creating JSON string in C#:

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace EKY.CSharpCornerJSONArticle
{
public class Student
{
public string name { get; set; }
}
public class Universities
{
public string university { get; set; }
public IList<Student> students { get; set; }
}
public class ClassUniversities
{
public Universities universities { get; set; }
}
class Program
{
static void Main(string[] args)
{
ClassUniversities university1 = new ClassUniversities();
university1.universities = new Universities();
university1.universities.university = "South Carolina State University";
List<Student> listStudent = new List<Student>();
Student student1 = new Student { name = "Stephen Cousins"};
Student student2 = new Student { name = "Austin A. Newton" };
Student student3 = new Student { name = "Adam Wilhite" };
Student student4 = new Student { name = "Enis Kurtay YILMAZ" };
listStudent.Add(student1);
listStudent.Add(student2);
listStudent.Add(student3);
listStudent.Add(student4);
university1.universities.students = listStudent;
string json = JsonConvert.SerializeObject(university1);
Console.WriteLine(json);
Console.ReadLine();
}
}
}

Result.

\wp content\uploads\2016\csharpcorner\picture6 - What is JSON And How To Using It In C#

 

How to read JSON string in C#

I think this part will be very easy for you. Just you need an example JSON string and JSON class of your example. You can use www.jsonutils.com again, if you want to create a class for your example JSON.

I will JSON strings from my website -> https://www.eniskurtayyilmaz.com/api/get_posts/

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Net;
using System.IO;
namespace EKY.CSharpCornerJSONArticle
{
public class Category
{
public int id { get; set; }
public string slug { get; set; }
public string title { get; set; }
public string description { get; set; }
public int parent { get; set; }
public int post_count { get; set; }
}
public class Tag
{
public int id { get; set; }
public string slug { get; set; }
public string title { get; set; }
public string description { get; set; }
public int post_count { get; set; }
}
public class Author
{
public int id { get; set; }
public string slug { get; set; }
public string name { get; set; }
public string first_name { get; set; }
public string last_name { get; set; }
public string nickname { get; set; }
public string url { get; set; }
public string description { get; set; }
}
public class CustomFields
{
}
public class Post
{
public int id { get; set; }
public string type { get; set; }
public string slug { get; set; }
public string url { get; set; }
public string status { get; set; }
public string title { get; set; }
public string title_plain { get; set; }
public string content { get; set; }
public string excerpt { get; set; }
public string date { get; set; }
public string modified { get; set; }
public IList<Category> categories { get; set; }
public IList<Tag> tags { get; set; }
public Author author { get; set; }
public IList<object> comments { get; set; }
public IList<object> attachments { get; set; }
public int comment_count { get; set; }
public string comment_status { get; set; }
public CustomFields custom_fields { get; set; }
}
public class Query
{
public bool ignore_sticky_posts { get; set; }
}
public class ClassWebsiteposts
{
public string status { get; set; }
public int count { get; set; }
public int count_total { get; set; }
public int pages { get; set; }
public IList<Post> posts { get; set; }
public Query query { get; set; }
} 
class Program
{
static void Main(string[] args)
{
string url = "https://www.eniskurtayyilmaz.com/api/get_posts/";
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
string jsonValue = "";
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
jsonValue = reader.ReadToEnd();
}
ClassWebsiteposts websitePosts = JsonConvert.DeserializeObject<ClassWebsiteposts>(jsonValue); 
}
}
}

Result.

\wp content\uploads\2016\csharpcorner\picture5 - What is JSON And How To Using It In C#

All of source code for downloading  http://download.eniskurtayyilmaz.com/csharpcornerarticle.rar

bagis genel 150x150 - What is JSON And How To Using It In C#
Enis Kurtay YILMAZ