You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Net;
using Microsoft.Net.Http;
using Microsoft.AspNetCore.WebUtilities;
namespace WebApiStudy.WebApp.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TestController : ControllerBase
{
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
[HttpGet("{id}", Name = "Get")]
public string Get(int id)
{
return "value";
}
//[Route("MyName")]
[HttpGet("GetName/{id:int}")]
public string GetName(int id)
{
var myName = "";
if (id >20)
{
myName = "wanggaofeng";
}
else
{
myName = "wangxiangqian";
}
return myName;
}
[HttpPost]
public void Post([FromBody] string value)
{
}
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}