Sfoglia il codice sorgente

非www跳转的bug修复

懒得勤快 6 anni fa
parent
commit
a3555a7220

+ 3 - 4
src/Masuit.MyBlogs.Core/Controllers/CommentController.cs

@@ -17,7 +17,6 @@ using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Text.RegularExpressions;
-using System.Web;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -118,7 +117,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                         //新评论,只通知博主和楼主
                         foreach (var s in emails.Distinct())
                         {
-                            BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer]) + "|博客文章新评论:", content.Replace("{{link}}", Url.Action("Details", "Post", new { id = com.PostId, cid = com.Id }, Request.Scheme) + "#comment"), s));
+                            BackgroundJob.Enqueue(() => CommonHelper.SendMail(CommonHelper.SystemSettings["Domain"] + "|博客文章新评论:", content.Replace("{{link}}", Url.Action("Details", "Post", new { id = com.PostId, cid = com.Id }, Request.Scheme) + "#comment"), s));
                         }
                     }
                     else
@@ -129,7 +128,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                         string link = Url.Action("Details", "Post", new { id = com.PostId, cid = com.Id }, Request.Scheme) + "#comment";
                         foreach (var s in emails)
                         {
-                            BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer])}{CommonHelper.SystemSettings["Title"]}文章评论回复:", content.Replace("{{link}}", link), s));
+                            BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{CommonHelper.SystemSettings["Domain"]}{CommonHelper.SystemSettings["Title"]}文章评论回复:", content.Replace("{{link}}", link), s));
                         }
                     }
 #endif
@@ -137,7 +136,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 }
                 foreach (var s in emails.Distinct())
                 {
-                    BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer]) + "|博客文章新评论(待审核):", content.Replace("{{link}}", Url.Action("Details", "Post", new { id = com.PostId, cid = com.Id }, Request.Scheme) + "#comment") + "<p style='color:red;'>(待审核)</p>", s));
+                    BackgroundJob.Enqueue(() => CommonHelper.SendMail(CommonHelper.SystemSettings["Domain"] + "|博客文章新评论(待审核):", content.Replace("{{link}}", Url.Action("Details", "Post", new { id = com.PostId, cid = com.Id }, Request.Scheme) + "#comment") + "<p style='color:red;'>(待审核)</p>", s));
                 }
                 return ResultData(null, true, "评论成功,待站长审核通过以后将显示");
             }

+ 3 - 4
src/Masuit.MyBlogs.Core/Controllers/MsgController.cs

@@ -16,7 +16,6 @@ using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Text.RegularExpressions;
-using System.Web;
 
 namespace Masuit.MyBlogs.Core.Controllers
 {
@@ -176,7 +175,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     if (msg.ParentId == 0)
                     {
                         //新评论,只通知博主
-                        BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer]) + "|博客新留言:", content.Replace("{{link}}", Url.Action("Index", "Msg", new { cid = msg2.Id }, Request.Scheme)), email));
+                        BackgroundJob.Enqueue(() => CommonHelper.SendMail(CommonHelper.SystemSettings["Domain"] + "|博客新留言:", content.Replace("{{link}}", Url.Action("Index", "Msg", new { cid = msg2.Id }, Request.Scheme)), email));
                     }
                     else
                     {
@@ -187,13 +186,13 @@ namespace Masuit.MyBlogs.Core.Controllers
                         string link = Url.Action("Index", "Msg", new { cid = msg2.Id }, Request.Scheme);
                         foreach (var s in emails.Distinct().Except(new[] { msg2.Email }))
                         {
-                            BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer])}{CommonHelper.SystemSettings["Title"]} 留言回复:", content.Replace("{{link}}", link), s));
+                            BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{CommonHelper.SystemSettings["Domain"]}{CommonHelper.SystemSettings["Title"]} 留言回复:", content.Replace("{{link}}", link), s));
                         }
                     }
 #endif
                     return ResultData(null, true, "留言发表成功,服务器正在后台处理中,这会有一定的延迟,稍后将会显示到列表中!");
                 }
-                BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer]) + "|博客新留言(待审核):", content.Replace("{{link}}", Url.Action("Index", "Msg", new
+                BackgroundJob.Enqueue(() => CommonHelper.SendMail(CommonHelper.SystemSettings["Domain"] + "|博客新留言(待审核):", content.Replace("{{link}}", Url.Action("Index", "Msg", new
                 {
                     cid = msg2.Id
                 }, Request.Scheme)) + "<p style='color:red;'>(待审核)</p>", email));

+ 2 - 2
src/Masuit.MyBlogs.Core/Extensions/NonWwwRule.cs

@@ -15,9 +15,9 @@ namespace Masuit.MyBlogs.Core.Extensions
                 return;
             }
 
-            if (req.Scheme.Equals("http"))
+            if (req.Scheme.Equals("http") || currentHost.Host.Contains("www."))
             {
-                context.HttpContext.Response.Redirect("https://" + currentHost.Host + req.PathBase + req.Path + req.QueryString);
+                context.HttpContext.Response.Redirect("https://" + currentHost.Host.Replace("www.", string.Empty) + req.PathBase + req.Path + req.QueryString);
                 context.Result = RuleResult.EndResponse;
             }
         }

+ 1 - 1
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.xml

@@ -92,7 +92,7 @@
             OSS客户端
             </summary>
         </member>
-        <member name="M:Common.CommonHelper.UploadSmms(System.String)">
+        <member name="M:Common.CommonHelper.UploadImage(System.String)">
             <summary>
             上传图片到sm图床
             </summary>