/****************************poco控制器********************************/
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace PocoDemo
{
[Controller]
public class Home
{
//第一种 按名称映射
[NonAction]
public IActionResult About()
{
return new ContentResult() { Content = "about" };
}
[ActionName("About")]
public IActionResult LoveGermanStepherds()
{
return new ContentResult() { Content = "about" };
}
//第二种 按照http动词映射
//[AcceptVerbs("post")]
//public IActionResult CallMe()
//{
// return new ContentResult() { Content = "callme" };
//}
//[AcceptVerbs("post","get")]
//public IActionResult CallMe()
//{
// return new ContentResult() { Content = "callme" };
//}
[HttpGet]
[HttpPost]
public IActionResult CallMe()
{
return new ContentResult() { Content = "callme" };
}
}
}
/************************index.cshtml********************************/
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
<h1>@ViewData.Model.Title</h1>
<form action="/home/callme" target="_self" method="post">
<input type="text" name="name" value="zhangsan"/>
<button type="submit" >submit</button>
</form>
@{
}