diff --git "a/\344\275\225\347\264\253\346\202\246/20241119-\346\216\247\345\210\266\345\231\250.md" "b/\344\275\225\347\264\253\346\202\246/20241119-\346\216\247\345\210\266\345\231\250.md" new file mode 100644 index 0000000000000000000000000000000000000000..0d9d232fb5568f44c6b042b3a1967fa5c7b0ec63 --- /dev/null +++ "b/\344\275\225\347\264\253\346\202\246/20241119-\346\216\247\345\210\266\345\231\250.md" @@ -0,0 +1,83 @@ +``` +using Microsoft.AspNetCore.Mvc; +using Blog.Models; +namespace Blog.Controllers; +public class BlogsController : Controller +{ + public IActionResult Index() + { + return View(); + } +} +``` + +### Linux练习 +### 1. +#### SSH客户端 +注意事项: + +确保SSH服务已在服务器上启动,并且客户端有正确的服务器地址和端口号(默认为22)。 + +使用公钥认证可以提高安全性,避免每次连接时输入密码。 + +可以通过ssh-keygen生成密钥对,并使用ssh-copy-id将公钥复制到服务器上以实现无密码登录。 + +确保SSH客户端配置文件(如~/.ssh/config)正确设置,以便快速连接。 + +#### Tabby应用 +注意事项: + +在获取密钥之前一定要在【设置】-【保险库】先创建一个主密码,但下面的加密配置文件不要打开。 + +Tabby支持多平台,包括Windows、Linux和MacOS,可以统一管理SSH连接。 + +支持SSH连接的同步功能,但同步功能可能需要付费。 + +支持命令的快捷输入,并且可以支持服务器之间文件的快速互传。 +#### xShell +注意事项: + +设置不间断连接,以防止服务器因为长时间无操作而断开连接。 + +关闭响铃,避免不必要的干扰。 + +关闭x11,因为免费版本不支持图形显示。 + +如果使用密钥登录,需要导入密钥文件。 + +可以调整视图设置,如前景色与背景色等。 +#### PuTTY +注意事项: + +允许用户定制字体、颜色、键盘映射等。 + +使用密钥文件进行SSH登录时,需要指定私钥文件的路径。 + +支持端口转发和X11转发,但需要正确配置。 + +PuTTY不支持内建的脚本执行功能,但可以通过命令行或创建快捷方式来自动化连接和设置的过程。 + +直接在命令行中包含明文密码不安全,推荐使用密钥认证。 + +#### 区别 +* SSH客户端:通常是操作系统自带的命令行工具,适用于Unix-like系统,功能强大但界面较为原始。 +* Tabby应用:是一个现代的终端连接工具,支持多平台,界面友好,功能丰富,但可能需要付费解锁全部功能。 +* xShell:是一个专为Windows设计的SSH客户端,界面友好,支持密钥登录和文件传输,适合需要图形界面的用户。 +* PuTTY:是一个经典的Windows SSH客户端,功能全面,定制性高,但界面相对传统。 +### 2.3.如图 +![](https://gitee.com/he-ziyueL/img/raw/master/20241124153458.png) +### 4.(1-6) +![](https://gitee.com/he-ziyueL/img/raw/master/20241124154935.png) + +(7-8) +![](https://gitee.com/he-ziyueL/img/raw/master/20241124160200.png) + +9.![](https://gitee.com/he-ziyueL/img/raw/master/20241124160113.png) + +10-12.![](https://gitee.com/he-ziyueL/img/raw/master/20241124160922.png) + +13.![](https://gitee.com/he-ziyueL/img/raw/master/20241124161146.png) + +14-20.![](https://gitee.com/he-ziyueL/img/raw/master/20241124161607.png) + +21-23.![](https://gitee.com/he-ziyueL/img/raw/master/20241124162712.png) \ No newline at end of file diff --git "a/\344\275\225\347\264\253\346\202\246/20241121-\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202.md" "b/\344\275\225\347\264\253\346\202\246/20241121-\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202.md" new file mode 100644 index 0000000000000000000000000000000000000000..0af56c05b528c7d685a7f43be1793f731d135af2 --- /dev/null +++ "b/\344\275\225\347\264\253\346\202\246/20241121-\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202.md" @@ -0,0 +1,37 @@ +1. 通过URL参数传递 + +可以直接在URL中添加参数 +``` +public ActionResult Details(int id) +{ + return View(); +} +``` +id 参数是通过URL传递的,例如:/Product/Details/1 + +2. [FromBody]传参 + +定义一个类接收 类名CreateDto 定义属性 访问前提: 类前面加请求方式[HttpPost] 参数前面加[FromBody] + +### MVC练习 +![](https://gitee.com/he-ziyueL/img/raw/master/20241124165640.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202024-11-24%20170016.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/20241124170739.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/20241124171046.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/20241124171215.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/20241124173356.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/20241124173913.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/20241124185401.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/20241124190753.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/20241124191557.png) + +![](https://gitee.com/he-ziyueL/img/raw/master/20241124192653.png) \ No newline at end of file diff --git "a/\344\275\225\347\264\253\346\202\246/20241122-MVC\351\241\271\347\233\256\345\217\212\347\273\203\344\271\240.md" "b/\344\275\225\347\264\253\346\202\246/20241122-MVC\351\241\271\347\233\256\345\217\212\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..668b38424cc288c72fa761d9664944fc35f78723 --- /dev/null +++ "b/\344\275\225\347\264\253\346\202\246/20241122-MVC\351\241\271\347\233\256\345\217\212\347\273\203\344\271\240.md" @@ -0,0 +1,46 @@ +模型(Model):负责数据和业务逻辑,通常包含数据存储、检索和业务规则。 +``` +namespace Blog.Models; +``` +### 专项练习-控制器传参 +1.![](https://gitee.com/he-ziyueL/img/raw/master/20241124193120.png) + +2.![](https://gitee.com/he-ziyueL/img/raw/master/20241124194055.png) + +3.![](https://gitee.com/he-ziyueL/img/raw/master/20241124200607.png) + +4.5.6.![](https://gitee.com/he-ziyueL/img/raw/master/20241124200304.png) + +### 专项练习-基础能力 +1.![](https://gitee.com/he-ziyueL/img/raw/master/20241124200820.png) +2.![](https://gitee.com/he-ziyueL/img/raw/master/20241124200926.png) +3.![](https://gitee.com/he-ziyueL/img/raw/master/20241124201525.png) +4.![](https://gitee.com/he-ziyueL/img/raw/master/20241124202620.png) +5.![](https://gitee.com/he-ziyueL/img/raw/master/20241124203800.png) +6.![](https://gitee.com/he-ziyueL/img/raw/master/20241124203918.png) +7.![](https://gitee.com/he-ziyueL/img/raw/master/20241124204133.png) + +### 专项练习-控制器返回值 +1.![](https://gitee.com/he-ziyueL/img/raw/master/20241124204314.png) +2.![](https://gitee.com/he-ziyueL/img/raw/master/20241124204349.png) +3. +``` +public IActionResult CollectionView() +{ + CollectionViewModel model = new CollectionViewModel + { + Items = new List { "Item1", "Item2", "Item3" } + }; + return View(model); +} +``` +``` +@model YourNamespace.CollectionViewModel + + +``` \ No newline at end of file