From 13f826dc30c572659d385cad4793810fa82797ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F=E9=91=AB?= <14089910+cwx050211@user.noreply.gitee.com> Date: Sun, 24 Nov 2024 13:56:17 +0000 Subject: [PATCH] =?UTF-8?q?add=20=E9=99=88=E4=BC=9F=E9=91=AB/202241124.md.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈伟鑫 <14089910+cwx050211@user.noreply.gitee.com> --- .../202241124.md" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "\351\231\210\344\274\237\351\221\253/202241124.md" diff --git "a/\351\231\210\344\274\237\351\221\253/202241124.md" "b/\351\231\210\344\274\237\351\221\253/202241124.md" new file mode 100644 index 0000000..b37948f --- /dev/null +++ "b/\351\231\210\344\274\237\351\221\253/202241124.md" @@ -0,0 +1,22 @@ +### 控制器传参 +#### 单个值传参 +``` +public IActionResult Index(int id) +{ + return Content(id.ToString()); +} +``` +#### 传递多个值 +``` +[HttpPost] +public IActionResult Create([FromBody] BlogCreateDto blogCreateDto) +{ + return Content(blogCreateDto.Title) +} +``` +``` +public class BlogCreateDto +{ + public string Title{get;set;}=null!; +} +``` -- Gitee