diff --git "a/\345\221\250\346\227\255/20241114\342\200\224\342\200\224\351\241\271\347\233\256\347\273\223\346\236\204.md" "b/\345\221\250\346\227\255/20241113\342\200\224\342\200\224\351\241\271\347\233\256\347\273\223\346\236\204.md" similarity index 100% rename from "\345\221\250\346\227\255/20241114\342\200\224\342\200\224\351\241\271\347\233\256\347\273\223\346\236\204.md" rename to "\345\221\250\346\227\255/20241113\342\200\224\342\200\224\351\241\271\347\233\256\347\273\223\346\236\204.md" diff --git "a/\345\221\250\346\227\255/20241118\342\200\224\342\200\224Linux\351\203\250\347\275\262.md" "b/\345\221\250\346\227\255/20241118\342\200\224\342\200\224Linux\351\203\250\347\275\262.md" new file mode 100644 index 0000000000000000000000000000000000000000..fa1b6cc0f2f5573b057919fe410583eea2d096f0 --- /dev/null +++ "b/\345\221\250\346\227\255/20241118\342\200\224\342\200\224Linux\351\203\250\347\275\262.md" @@ -0,0 +1,31 @@ +## 创建一个Controllers + +``` + //引用命名空间,但是在引入之间,如果不是SDK自带的包的话,需要先安装依赖包 + +using Microsoft.AspNetCore.Mvc; + //新版的命名空间形式 +namespace Blog.Controllers; + //控制器(本质其实是一个类型,通过继承Controller这个类型来获得所有关于控制器的功能) +public class BlogController:Controller{ + //IActionResult:专业名称叫action,本质上其实是一个方法(方法三要素:方法名称,参数,返回值) +public IActionResult 方法名(){ + return View() + } +} +``` + +## 视图返回内容在控制器中 + +- 生成随机数 + +``` +public string Create(){ + var rnd=new Random(); + return rnd.Next().Tostring(); //需要将int类型显式转换为字符串 +} +``` + +- dotnet watch:热重载 dotnet publish:部署打包命令 + +### 按shift+鼠标右键打开powerShell窗口 \ No newline at end of file