.NET Core Web API

.NET Core实现了.NET Standard,支持跨平台运行,包括Windows、macOS和Linux。相比之下,.NET Framework仅限Windows并包含特定框架如WPF。Mono主要用于Android和Apple系统,驱动Xamarin和Unity。UWP统一了微软设备的接口。本文还探讨了HTTPS和HTTP协议,并给出了Web API POST请求的示例。
摘要由CSDN通过智能技术生成

.NET 实现

.NET Core:完全实现.NET Standard,可在Windows、macOS和Linux运行

.NET Framework:4.5以上实现.NET Standard,仅Windows。很多独有的框架,如WPF。

Mono:用于Android和所有Apple系统,驱动Xamarin和Unity

UWP:统一微软各类设备(Windows、Xbox、Windows Phone等)

https和http协议

Web API Post实例:

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebAPI_Core.Models;

namespace WebAPI_Core.Controllers
{
    [Route("api/[controller]")]  //路由
    [ApiController]
    public class ValuesController : ControllerBase
    {
        private static Dictionary<string, AddRequest> DB = new Dictionary<string, AddRequest>();

        // POST api/<ValuesController>
        [HttpPost]
        public AddResponse Post([FromBody] AddRequest req)
        {
            AddResponse resp = new AddResponse();
            try
            {
                DB.Add(req.ISBN,req);
                resp.ISBN = req.ISBN;
                resp.message = "交易成功";
                resp.result = "success";


            }catch(Exception ex)
            {
                Console.WriteLine(ex.ToString());
                resp.ISBN = "";
                resp.message = "交易失败";
                resp.result = "fail";
            }

            return resp;
        }

        /* AddRequest
        {
        	"ISBN": "1",
        	
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值