From 481e82072bd4aa268a52d306340ba673e2661f70 Mon Sep 17 00:00:00 2001 From: 1 <3248962241@qq.com> Date: Sun, 24 Nov 2024 20:13:37 +0800 Subject: [PATCH] 1124 --- ...21\347\253\231\347\254\224\350\256\260.md" | 31 ++++++++++ ...76\345\217\212\347\254\224\350\256\260.md" | 0 ...30\351\207\217\347\254\224\350\256\260.md" | 20 +++++++ ...\213linux+MVC\347\273\203\344\271\2401.md" | 56 +++++++++++++++++++ ...40\345\217\202\347\254\224\350\256\260.md" | 21 +++++++ ...36\345\200\274\344\275\234\344\270\232.md" | 32 +++++++++++ ...66\345\231\250\344\274\240\345\217\202.md" | 23 ++++++++ 7 files changed, 183 insertions(+) create mode 100644 "\350\202\226\347\276\216\345\221\210/1112-\346\220\255\345\273\272mvc\347\275\221\347\253\231\347\254\224\350\256\260.md" rename "\350\202\226\347\276\216\345\221\210/20241114-mvc\347\273\203\344\271\240\345\217\212\347\254\224\350\256\260.md" => "\350\202\226\347\276\216\345\221\210/1114-mvc\347\273\203\344\271\240\346\210\252\345\233\276\345\217\212\347\254\224\350\256\260.md" (100%) create mode 100644 "\350\202\226\347\276\216\345\221\210/1115-\347\216\257\345\242\203\345\217\230\351\207\217\347\254\224\350\256\260.md" create mode 100644 "\350\202\226\347\276\216\345\221\210/1119\347\254\224\350\256\260\357\274\213linux+MVC\347\273\203\344\271\2401.md" create mode 100644 "\350\202\226\347\276\216\345\221\210/1121-\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202\347\254\224\350\256\260.md" create mode 100644 "\350\202\226\347\276\216\345\221\210/1122-\345\237\272\347\241\200\350\203\275\345\212\233+\346\216\247\345\210\266\345\231\250\350\277\224\345\233\236\345\200\274\344\275\234\344\270\232.md" create mode 100644 "\350\202\226\347\276\216\345\221\210/1122\347\254\224\350\256\260+\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202.md" diff --git "a/\350\202\226\347\276\216\345\221\210/1112-\346\220\255\345\273\272mvc\347\275\221\347\253\231\347\254\224\350\256\260.md" "b/\350\202\226\347\276\216\345\221\210/1112-\346\220\255\345\273\272mvc\347\275\221\347\253\231\347\254\224\350\256\260.md" new file mode 100644 index 0000000..5473256 --- /dev/null +++ "b/\350\202\226\347\276\216\345\221\210/1112-\346\220\255\345\273\272mvc\347\275\221\347\253\231\347\254\224\350\256\260.md" @@ -0,0 +1,31 @@ +ping 域名 + +ssh root@域名 输入密码 + +apt update + +apt upgrade-y + +syestemctl status nginx + +apt install nginx -y(安装) + +mkdir /var/www + +cd /var/www + +mkdir 域名 + +cd 域名 + +vim index.html 12 .cat index.html + +cd /etc/nginxx/conf.d/ + +vim 域名.conf + +server{ listen 80; #监听的端口 server_name 9ihub.com; #监听的域名 location / { root /var/www/9ihub.com ;#网站所在路径 index index.html; #默认的首页文件 } } + +nginx -t + +nginx -s reload \ No newline at end of file diff --git "a/\350\202\226\347\276\216\345\221\210/20241114-mvc\347\273\203\344\271\240\345\217\212\347\254\224\350\256\260.md" "b/\350\202\226\347\276\216\345\221\210/1114-mvc\347\273\203\344\271\240\346\210\252\345\233\276\345\217\212\347\254\224\350\256\260.md" similarity index 100% rename from "\350\202\226\347\276\216\345\221\210/20241114-mvc\347\273\203\344\271\240\345\217\212\347\254\224\350\256\260.md" rename to "\350\202\226\347\276\216\345\221\210/1114-mvc\347\273\203\344\271\240\346\210\252\345\233\276\345\217\212\347\254\224\350\256\260.md" diff --git "a/\350\202\226\347\276\216\345\221\210/1115-\347\216\257\345\242\203\345\217\230\351\207\217\347\254\224\350\256\260.md" "b/\350\202\226\347\276\216\345\221\210/1115-\347\216\257\345\242\203\345\217\230\351\207\217\347\254\224\350\256\260.md" new file mode 100644 index 0000000..714bebd --- /dev/null +++ "b/\350\202\226\347\276\216\345\221\210/1115-\347\216\257\345\242\203\345\217\230\351\207\217\347\254\224\350\256\260.md" @@ -0,0 +1,20 @@ +# 关键步骤 +```` +建一个文件夹 mkdir Blog (文件夹的名字) + +2.在此文件夹里面建一个解决方案 dotnet new sln -o .\Blog\ + +3.路径 mkdir .\Blog\scr + +4.只有项目没有解决方案 dotnet new mvc -o Blog + +切换 cd.. + +dotnet bulid 编译 + +引用 + +Controllers 控制器 + +结束端口运行 ctrl+c 或者是 ctrl+z +```` \ No newline at end of file diff --git "a/\350\202\226\347\276\216\345\221\210/1119\347\254\224\350\256\260\357\274\213linux+MVC\347\273\203\344\271\2401.md" "b/\350\202\226\347\276\216\345\221\210/1119\347\254\224\350\256\260\357\274\213linux+MVC\347\273\203\344\271\2401.md" new file mode 100644 index 0000000..a72f12d --- /dev/null +++ "b/\350\202\226\347\276\216\345\221\210/1119\347\254\224\350\256\260\357\274\213linux+MVC\347\273\203\344\271\2401.md" @@ -0,0 +1,56 @@ +# 这是笔记 +将一个Asp.Net Core MVC部署分几步 +```` +第一步,将程序扔到服务器 + * a打包程序 dotnet publish (打包的程序位于如下文件夹:bin/Release/net8.0/publish) + * b使用一些工具将打包好的程序转到服务器,比如Scp命令 sftp工具 +第二步,安装dotnet运行时 答案是Debian这个Linux的发行版本 + 安装的方式有几种 + 包管理器 + 下载一个文件 + 将文件安装(下载一个源地址文件,安装到软件源地址) + 更新软件源 + 安装SDK + 二进制文件 + 编译安装 +```` + +# linux +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/20241124165032.png) + +# mvc练习 +第一题.项目名称通常用于标识项目,它在文件系统中作为项目的文件夹名称,也在解决方案资源管理器中显示,项目名称应避免使用非法字符和空格 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/7cf95a7543bef3a89a8f2778c68402b.png) + +第二题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/9d5ab6d3e9ec9365cefc4b5ff4a0e10.png) + +第三题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/ca2aa8e3c2b6f0df4c4f95712e7fe30.png) + +第四题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/f127c657e31d505449902b9c92b8b2f.png) + +第五题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/d826c6450427431f91344285ffc250d.png) + +第六题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/5361360709558e668f23389c4097717.png) + +第七题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/8b6af01d6521f8cf42c7e11e622400c.png) + +第八题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/87df9357a7100fe86a3e4cfbea97866.png) + +第九题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/79bccdf4e144f1973d2d6c7cbcc9050.png) + +第十题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/8430c0722f0cd8b57700d6d108e482a.png) + +第十一题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/7a6cfc7ed6e64c113492f3f7b207071.png) + +第十二题 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/54e59f40148c7703b93404692640d6f.png) diff --git "a/\350\202\226\347\276\216\345\221\210/1121-\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202\347\254\224\350\256\260.md" "b/\350\202\226\347\276\216\345\221\210/1121-\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202\347\254\224\350\256\260.md" new file mode 100644 index 0000000..5f3a238 --- /dev/null +++ "b/\350\202\226\347\276\216\345\221\210/1121-\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202\347\254\224\350\256\260.md" @@ -0,0 +1,21 @@ +# 基本结构 +文件夹 解决方案(创建语法 : dotnet new sln -n 解决方案名) + +src文件夹(里面的子级文件统称项目) + +mvc项目(一个 | 创建语法 : dotnet new mve -o mvc项目名) + +类库(多个 | 创建语法 : dotnet new calsslib -o 类库名) + + +mvc项目.csproj -> 配置文件(定义项目的依赖项、输出项等信息) +program.cs -> 应用程序的入口 +wwwroot -> 存放静态文件(css、js、图片等文件 | 这些文件可以通过浏览器直接访问)、 +views -> 视图(需要跟控制器一一对应 | 控制器类名(去掉Controllr) =》 文件夹名称 / 控制器 +类名的方法名 =》 控制器类名内的方法名.cshtml文件 +controllers -> 控制器(命名需要加上Controller) + +简单的基本语法: +obj 和 bin -> 缓存软件 +Models -> 存放应用程序的数据模型(一般是数据库) +appsettings.json -> 存储应用程序的配置信息 \ No newline at end of file diff --git "a/\350\202\226\347\276\216\345\221\210/1122-\345\237\272\347\241\200\350\203\275\345\212\233+\346\216\247\345\210\266\345\231\250\350\277\224\345\233\236\345\200\274\344\275\234\344\270\232.md" "b/\350\202\226\347\276\216\345\221\210/1122-\345\237\272\347\241\200\350\203\275\345\212\233+\346\216\247\345\210\266\345\231\250\350\277\224\345\233\236\345\200\274\344\275\234\344\270\232.md" new file mode 100644 index 0000000..4c920a0 --- /dev/null +++ "b/\350\202\226\347\276\216\345\221\210/1122-\345\237\272\347\241\200\350\203\275\345\212\233+\346\216\247\345\210\266\345\231\250\350\277\224\345\233\236\345\200\274\344\275\234\344\270\232.md" @@ -0,0 +1,32 @@ + +生成一个随机整数,范围[0,100],注意是否包含 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/e51e6bc0e572f8e45fcfe5bb2e1ba3b.png) + +生成一个随机整数,范围(0,100],注意是否包含 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/733ab347d7f561baaff7c477370a862.png) + +生成10个随机整数,范围[5,80],注意是否包含 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/a049a803258eeab4a575f13558799a2.png) + +定义一个字符串,字符串中有100个中文字符,需要从中随机取1个字符串 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/358927ac41e5def2d85c4df603c7777.png) + +定义一个字符串,字符串中有100个中文字符,需要从中随机取5-50个字符,组成新的字符 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/837a1eeef505498cf82bd7a1ff7d04d.png) + +定义2个字符串,第一个字符串中放百家姓,第二个字符串中放中文字符,要求从第一个字符串随机取得一个姓,再从第二个字符串中随机获得1到2个字符组成新字符串,和第一个字符串取得的姓组成一个姓名 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/49a7a608bafc8398298e60781540619.png) + +利用以上方法,随机生成100个BlogCreateDto类型(有Title、Author、Content属性)的对象,其中的内容都是随机生成且长度不定,并将其渲染到视图 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/2f5fc7fb71653e329cbc6241cc28e0e.png) + + +渲染简单数据到页面 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/20241124141219.png) + +渲染复杂数据到页面 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/20241124141050.png) + +渲染集合数据到页面 +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/7d0f882cb6173a8b38f6bbd32ca9d5d.png) +![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/76728a590abd7e996edbfc1f73584bf.png) diff --git "a/\350\202\226\347\276\216\345\221\210/1122\347\254\224\350\256\260+\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202.md" "b/\350\202\226\347\276\216\345\221\210/1122\347\254\224\350\256\260+\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202.md" new file mode 100644 index 0000000..bb9702e --- /dev/null +++ "b/\350\202\226\347\276\216\345\221\210/1122\347\254\224\350\256\260+\346\216\247\345\210\266\345\231\250\344\274\240\345\217\202.md" @@ -0,0 +1,23 @@ +# 这是笔记 +* 控制器返回类型 + 一般数据类型 直接返回如int,double,string,IEnumerable等数据类型 + IAtionResult类型 一个接口,用于返回HTTP状态信息,如200,301,401,404,500等 + 视图 + 重定向 + ActionResult类型 讲一般数据类型和HTTP状态信息混合使用 + 特定于格式的操作结果:如JsonResult和ContentResult + POCO(普通旧CLR对象) + + # 控制器传参作业 + 1.![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/758292687fc1b384cf408f8e9e9810c.png) + + 2.![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/a826d455c43e6d16d94875482aac644.png) + + 3.![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/3a43114d8e7d98ff711936c1b86db8a.png) + + 4.![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/2668c4e3dea9e9821173658d8368326.png) + + 5.![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/c907449e417d4f12fd64270c063aa48.png) + + 6.![](https://gitee.com/xiao-meicheng/picture-bed/raw/master/ce3d7ca55ae8f9acd9a9d445e110ee5.png) + -- Gitee