WEB - / REST Server under .NET4.8

Markus Freitag 3,791 Reputation points
2021-12-18T16:35:12.223+00:00

Hello,

What is the right way to create a web server under .NET4.8. Do you have an example.
It seems easier on .NET6. Unfortunately I do not have this version available.

I create a GET request and a JSON response comes back as a response. Do you have a demonstration?
The best is with WPF desktop application.

 var builder = WebApplication.CreateBuilder(args); 
 var app = builder.Build(); 
 var fileName = "counter.txt"; 
 var counter = 0; 

 if (!File.Exists(fileName)) 
     File.Create(fileName).Close(); 
 else 
     counter = int.Parse(File.ReadAllText(fileName)); 

 app.MapGet("/", () =>  
 { 
     lock(app)
     {
         ++counter; 
         File.WriteAllText(fileName,counter.ToString()); 
     }
     return counter; 
 }); 

 app.Run(); 
Microsoft Partner Center API
Windows for business Windows Server User experience Other
Developer technologies ASP.NET Other
Developer technologies C#
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2021-12-18T17:21:44.197+00:00

    Your question is not clear.

    Typically with 4.8 you would create a webapi project that is hosted by IIS. IIS supplies the main request pipline, and your project just supplies callbacks. The closest to your sample is a http module

    https://learn.microsoft.com/en-us/previous-versions/aspnet/ms227673(v=vs.100)

    If you meant a self hosting web server not hosted by IIS, then you use the self hosting module

    https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/self-host-a-web-api

    Or you can use owin

    https://learn.microsoft.com/en-us/aspnet/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api

    2 people found this answer helpful.

  2. Limitless Technology 39,916 Reputation points
    2021-12-21T16:11:22.507+00:00

    Hi @Markus Freitag

    NET Framework 4.8 was the final version. NET Framework, future work going into the rewritten and cross-platform. You can check through the below articles which will help you in broadening your insights on.NET4.8.

    How to: Install and Configure Internet Information Services for Microsoft Dynamics NAV Web Client
    https://learn.microsoft.com/en-us/dynamics-nav/how-to--install-and-configure-internet-information-services-for-microsoft-dynamics-nav-web-client

    ASP.NET 4 - Enterprise Deployment Introduction
    https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/deploying-web-applications-in-enterprise-scenarios/

    ASP.NET Web Deployment using Visual Studio: Deploying to Test
    https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-to-iis

    Hope this resolves your Query!!

    --If the reply is helpful, please Upvote and Accept it as an answer--

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.