• Stars
    star
    185
  • Rank 208,271 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C# Web Server

A simple C# web server created for educational purposes.

Steps to create a similar web server from scratch:

  1. Choose the localhost IP address (127.0.0.1) and a free local port
  2. Create a TcpListener and accept incomming client request asynchronously
  3. Write a valid HTTP response and convert it to a byte array
  4. Add Content-Type and Content-Length headers (be careful with UTF8 characters)
  5. Read the request in chunks (1024 bytes each) and store it in a StringBuilder
  6. Extract separate server and HTTP classes
  7. Parse the HTTP request
  8. Create routing table which should allow various HTTP methods
  9. Make sure the HTTP server can populate the routing table
  10. Create specific HTTP response classes - TextResponse, for example
  11. Implement the ToString method for the HTTP response class
  12. Implement the routing table for storing and retrieving request mapping
  13. Use the routing table in the HTTP server for actual request-response matching and execution
  14. Separate the URL and parse the query string if it exists
  15. Introduce the option to use the request by storing request-response functions in the routing table
  16. Introduce base controllers and extract common functionalities
  17. Shorten the route syntax and add support for controllers
  18. Add redirect HTTP response and use the Location header
  19. Add view response class and reuse functionality from the HTML response for setting the content
  20. Add functionality to find specific views by path and by convention
  21. Make sure the project copies the view files into the output directory
  22. Add functionality in the base controller class to get the view and controller names by convention
  23. Add functionality to parse the request form when the specific content type is present
  24. Add functionality for extracting model data via reflection and replacing it in the HTML
  25. Add functionality for storing and retrieving HTTP cookies
  26. Add functionality for storing HTTP session
  27. Add global exception handling and log all requests and responses in the console
  28. Use session to store the currently authenticated user ID and write helper methods for authentication
  29. Add static files option by choosing a public folder and adding all files in it as GET requests in the route table
  30. Make sure the HTTP server handles byte array response bodies
  31. Add automatic controller discovery by using reflection and mapping all public methods into the route table by convention
  32. Add HttpGet and HttpPost attributes to automatically register the HTTP method of the action
  33. Add Authorize attribute and short-circuit the request if there is no authenticated user
  34. Implement a layout page logic and insert the view content in it
  35. Use reflection to analyze the action parameters and populate them automatically from the request
  36. Remove the required constructor on the base Controller class and populate the request property automatically
  37. Introduce proper collections for headers, cookies, form and query
  38. Implement service collection with configuration and create controllers by using a dependendency resolver with reflection and recursion
  39. Add advanced view engine features - conditionals statements and loops
  40. Introduce user information during view rendering

Potential Tasks:

  • Introduce model state and automatic validation
  • Cache
  • Include the view files into the assemblies
  • Allow headers with the same name
  • Make the setter of the controller request private
  • Introduce server features to separate the abstraction for routing and services

More Repositories

1

MyTested.AspNetCore.Mvc

Fluent testing library for ASP.NET Core MVC.
C#
1,724
star
2

MyTested.WebApi

Fluent testing framework for ASP.NET Web API 2.
C#
755
star
3

AspNet.Mvc.TypedRouting

A collection of extension methods providing strongly typed routing and link generation for ASP.NET Core MVC projects.
C#
485
star
4

Architecture-of-ASP.NET-Core-Microservices-Applications

Architecture of ASP.NET Core Microservices Applications
C#
281
star
5

ASP.NET-Server-Architectures

C#
185
star
6

Software-Architecture-Series

Become a better software engineer πŸ‘ˆ
162
star
7

C-Sharp-Async-Await-In-Detail

JavaScript
156
star
8

ASP.NET-Core-Project-Car-Renting-System

C#
142
star
9

ASP.NET-MVC-Lambda-Expression-Helpers

A collection of extension methods providing strongly typed link generation for ASP.NET MVC 5 projects.
C#
139
star
10

Domain-Driven-Design-with-ASP.NET-Core-Microservices

Domain-Driven Design with ASP.NET Core Microservices
C#
123
star
11

AspNetCore.Mvc.HttpActionResults

A collection of HTTP status code action results and controller extension methods for ASP.NET Core MVC projects.
C#
100
star
12

CSharp-ORM-Battle

C#
100
star
13

Docker-From-ABC-To-XYZ

93
star
14

Identity-Server-Demystified

C#
93
star
15

Let-s-Get-Functional-With-C-Sharp

C#
86
star
16

MyCoolWebServer

C#
84
star
17

Microservice-Based-Applications

80
star
18

Microservices-Eventual-Consistency-Done-Right

C#
79
star
19

Process-Automation-with-ASP.NET-Core-Microservices

C#
75
star
20

C-Sharp-API-Scenarios-REST-GraphQL-gRPC

C#
64
star
21

GameStoreSimpleMvc

C#
55
star
22

JustChess

Console Chess Game for the OOP course at Telerik Academy
C#
54
star
23

MyTested.HttpServer

Fluent testing framework for remote HTTP servers.
C#
51
star
24

Ticketing-System-ASP.NET-MVC-5

Exam preparation for the Telerik Academy ASP.NET MVC 5 course.
C#
46
star
25

Telerik-Academy-Courses

MEAN Stack Application
CSS
45
star
26

Music-Artists

JavaScript
38
star
27

TestRepoCode

Testing GitHub
C#
36
star
28

express-architecture

JavaScript
36
star
29

express-template

Per type architecture for Node.js, Express, Mongoose and Handlebars.
JavaScript
35
star
30

AzurePipelinesBlog

C#
34
star
31

LearningSystemDemo

C#
32
star
32

ModPanel

C#
31
star
33

Jetpack-Joyride-Unity-3D

C#
30
star
34

Cool-Demo-Project

This is my cool demo project for a SoftUni lecture!
C#
27
star
35

AngularJS-SocialNetwork

JavaScript
25
star
36

ExpressionTrees

C#
25
star
37

ivaylokenov

24
star
38

Telerik-Academy-Tasks

My programming experience at Telerik Academy
JavaScript
23
star
39

Flappy-Bird-Unity-3D

C#
20
star
40

TestGitRepo

This is a test repository.
20
star
41

mocking-demo

C#
19
star
42

EasyPTC

C#
19
star
43

Student-System-Live-Demo

Entity Framework Code First and Repository Pattern Live Demo
JavaScript
18
star
44

DynamicXMLBuilder

C#
18
star
45

MVC.Models

JavaScript
17
star
46

TelerikHackaton.Ruler

C#
16
star
47

Roslyn-Overview

Overview of the .NET Compiler Platform
C#
16
star
48

Street-Fitness-Kendo-Mobile

KendoMobileStreetFitness
JavaScript
13
star
49

SoftUniDemoGitHubProject

Demo project for SoftUni Fundamentals
12
star
50

TestGit

Using this repository for a GitHub lecture at SoftUni
JavaScript
10
star
51

FundamentalsGitHubDemo

This is a demo repository for a lecture at SoftUni.
JavaScript
4
star