Develop Asp.Net Core Web Programs Using C#

Develop Asp.Net Core Web programs using WebAPI.Client.
  1. Use Visual Studio 2022 to develop software, create a new Asp.Net Core Web Application project
  2. Add project reference:IoT.API.WebApi.Client.dll
  3. Find Program.cs and add the following code to the Main method:
                            
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.Hosting;
    using Microsoft.Extensions.Logging;
    using IoT.API.WebApi.Client;
    
    namespace IoT.Example.WebApp
    {
        public class Program
        {
            public static void Main(string[] args)
            {
                AppClient.GetInstance().Initialize("9b90ddc743c44125a67f0f847749b19c", "User-3", "NGY5OTAwMzRkNWZlNDI4MzgzZDc0ODBkZGQwZDEzNmM=");
                CreateHostBuilder(args).Build().Run();
            }
    
            public static IHostBuilder CreateHostBuilder(string[] args) =>
                Host.CreateDefaultBuilder(args)
                    .ConfigureWebHostDefaults(webBuilder =>
                    {
                        webBuilder.UseStartup();
                    });
        }
    }
                            
                        
  4. After completing the above operations, you can use AppClient.GetInstance() to call the Web API function in the program. Please refer to the sample program for details.



Download the Asp.Net Core Web sample program

Asp.Net Core Web sample program, the operating environment requirements are .Net Core 5

  1. Example Source Code:https://cloud.tzonedigital.cn/f/dev/Example.WebApp/source_code.zip