1
0
懒得勤快 3 жил өмнө
parent
commit
faaa5e1a35

+ 5 - 0
src/Masuit.MyBlogs.Core/Controllers/ErrorController.cs

@@ -119,6 +119,11 @@ namespace Masuit.MyBlogs.Core.Controllers
 
         private static async Task<string> GetRequestBody(HttpRequest req)
         {
+            if (req.ContentLength > 5120)
+            {
+                return "请求体超长";
+            }
+
             req.Body.Seek(0, SeekOrigin.Begin);
             using var sr = new StreamReader(req.Body, Encoding.UTF8, false);
             var body = await sr.ReadToEndAsync();

+ 7 - 6
src/Masuit.MyBlogs.Core/Controllers/FileController.cs

@@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Mvc;
 using Polly;
 using System.Diagnostics;
 using System.Text;
+using Masuit.Tools.AspNetCore.ModelBinder;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -33,13 +34,13 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <param name="path"></param>
         /// <returns></returns>
-        public ActionResult GetFiles(string path)
+        public ActionResult GetFiles([FromBodyOrDefault] string path)
         {
-            using var files = Directory.GetFiles(HostEnvironment.WebRootPath + path).OrderByDescending(s => s).Select(s => new
+            var files = Directory.GetFiles(HostEnvironment.WebRootPath + path).OrderByDescending(s => s).Select(s => new
             {
                 filename = Path.GetFileName(s),
                 path = s
-            }).ToPooledList();
+            });
             return ResultData(files);
         }
 
@@ -48,7 +49,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <param name="filename"></param>
         /// <returns></returns>
-        public ActionResult Read(string filename)
+        public ActionResult Read([FromBodyOrDefault] string filename)
         {
             if (System.IO.File.Exists(filename))
             {
@@ -64,7 +65,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="filename"></param>
         /// <param name="content"></param>
         /// <returns></returns>
-        public ActionResult Save(string filename, string content)
+        public ActionResult Save([FromBodyOrDefault] string filename, [FromBodyOrDefault] string content)
         {
             try
             {
@@ -83,7 +84,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <returns></returns>
         [HttpPost]
-        public async Task<ActionResult> Upload(string destination)
+        public async Task<ActionResult> Upload([FromBodyOrDefault] string destination)
         {
             var form = await Request.ReadFormAsync();
             foreach (var t in form.Files)

+ 1 - 1
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/system.js

@@ -243,7 +243,7 @@ myApp.controller("log", ["$scope", function ($scope) {
 }]);
 myApp.controller("email", ["$scope", "$http", function ($scope) {
 	$scope.getfiles = function () {
-		$scope.request("/file/Getfiles", {path:"/template"}, function (data) {
+		$scope.get("/file/Getfiles?path=\\template", function (data) {
 			$scope.files = data.Data;
 		});
 	}

+ 1 - 1
src/Masuit.MyBlogs.Core/wwwroot/template/about.html

@@ -1,6 +1,6 @@
 <div class="row" style="font-size: 18px;line-height: 24px;">
     <div class="col-md-2">
-        <img src="https://git.imweb.io/ldqk/imgbed/raw/master/20190606/5dc7fc1266bfd8109d1ef5e0e7630f2c_2_3_art.png" alt="懒得勤快" class="img-responsive img-thumbnail" style="width: 100%" />
+        <img src="https://pic.ldqkcdn.top/20190606/5dc7fc1266bfd8109d1ef5e0e7630f2c_2_3_art.png" alt="懒得勤快" class="img-responsive img-thumbnail" style="width: 100%" />
     </div>
     <div class="col-md-10">
         <table class="table-responsive table-condensed">