Skip to content

Commit

Permalink
非www跳转的bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
ldqk committed May 2, 2019
1 parent 490bacb commit a3555a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
7 changes: 3 additions & 4 deletions src/Masuit.MyBlogs.Core/Controllers/CommentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;

namespace Masuit.MyBlogs.Core.Controllers
{
Expand Down Expand Up @@ -118,7 +117,7 @@ public ActionResult Put(CommentInputDto comment)
//新评论,只通知博主和楼主
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
Expand All @@ -129,15 +128,15 @@ public ActionResult Put(CommentInputDto comment)
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
return ResultData(null, true, "评论发表成功,服务器正在后台处理中,这会有一定的延迟,稍后将显示到评论列表中");
}
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, "评论成功,待站长审核通过以后将显示");
}
Expand Down
7 changes: 3 additions & 4 deletions src/Masuit.MyBlogs.Core/Controllers/MsgController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;

namespace Masuit.MyBlogs.Core.Controllers
{
Expand Down Expand Up @@ -176,7 +175,7 @@ public ActionResult Put(LeaveMessageInputDto msg)
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
{
Expand All @@ -187,13 +186,13 @@ public ActionResult Put(LeaveMessageInputDto msg)
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));
Expand Down
4 changes: 2 additions & 2 deletions src/Masuit.MyBlogs.Core/Extensions/NonWwwRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public void ApplyRule(RewriteContext context)
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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a3555a7

Please sign in to comment.