完善系统设置,增加404页面
This commit is contained in:
@@ -8,12 +8,21 @@ using COMCMS.Core;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using COMCMS.Web.Common;
|
using COMCMS.Web.Common;
|
||||||
|
using COMCMS.Core.Models;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||||
{
|
{
|
||||||
[Area("AdminCP")]
|
[Area("AdminCP")]
|
||||||
public class SystemController : AdminBaseController
|
public class SystemController : AdminBaseController
|
||||||
{
|
{
|
||||||
|
private IHostingEnvironment _env;
|
||||||
|
public SystemController(IHostingEnvironment env)
|
||||||
|
{
|
||||||
|
_env = env;
|
||||||
|
}
|
||||||
|
|
||||||
#region 系统基本设置
|
#region 系统基本设置
|
||||||
[MyAuthorize("view", "baseconfig")]
|
[MyAuthorize("view", "baseconfig")]
|
||||||
public IActionResult BaseConfig()
|
public IActionResult BaseConfig()
|
||||||
@@ -51,5 +60,148 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region SMTP 配置
|
||||||
|
[MyAuthorize("view", "smptconfig")]
|
||||||
|
public IActionResult SmtpConfig()
|
||||||
|
{
|
||||||
|
Config cfg = Config.GetSystemConfig();
|
||||||
|
SMTPConfigEntity smtp = cfg.SMTPConfigEntity;
|
||||||
|
Admin.WriteLogActions("查看SMTP配置;");
|
||||||
|
return View(smtp);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize( "view", "smptconfig", "JSON")]
|
||||||
|
public IActionResult SmtpConfig(SMTPConfigEntity model)
|
||||||
|
{
|
||||||
|
//验证
|
||||||
|
if (!Utils.IsValidEmail(model.SmtpEmail))
|
||||||
|
{
|
||||||
|
tip.Message = "SMTP帐号格式错误!请输入正确的Email!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.SmtpHost))
|
||||||
|
{
|
||||||
|
tip.Message = "请输入SMTP服务器地址!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
if (!Utils.IsInt(model.SmtpProt))
|
||||||
|
{
|
||||||
|
tip.Message = "请输入正确的端口号!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
string json = JsonConvert.SerializeObject(model);
|
||||||
|
|
||||||
|
OtherConfig oc = OtherConfig.Find(OtherConfig._.ConfigName == "smtp");
|
||||||
|
|
||||||
|
if (oc == null)//如果不存在
|
||||||
|
{
|
||||||
|
oc = new OtherConfig();
|
||||||
|
oc.ConfigName = "smtp";
|
||||||
|
oc.ConfigValue = JsonConvert.SerializeObject(model);
|
||||||
|
oc.LastUpdateTime = DateTime.Now;
|
||||||
|
oc.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oc.ConfigValue = JsonConvert.SerializeObject(model);
|
||||||
|
oc.LastUpdateTime = DateTime.Now;
|
||||||
|
oc.Update();
|
||||||
|
}
|
||||||
|
Admin.WriteLogActions("修改SMTP设置;");
|
||||||
|
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Message = "修改站点SMTP配置成功";
|
||||||
|
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 附件配置
|
||||||
|
[MyAuthorize( "view", "attachconfig")]
|
||||||
|
public IActionResult AttachConfig()
|
||||||
|
{
|
||||||
|
Config cfg = Config.GetSystemConfig();
|
||||||
|
AttachConfigEntity model = cfg.AttachConfigEntity;
|
||||||
|
Admin.WriteLogActions("查看附件配置;");
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("view", "attachconfig", "JSON")]
|
||||||
|
public IActionResult AttachConfig(AttachConfigEntity model)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(model.WaterMarkImg))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!System.IO.File.Exists(Path.Combine(_env.WebRootPath, model.WaterMarkImg)))
|
||||||
|
{
|
||||||
|
tip.Message = "水印图片不存在,请重新上传!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string json = JsonConvert.SerializeObject(model);
|
||||||
|
|
||||||
|
OtherConfig oc = OtherConfig.Find(OtherConfig._.ConfigName == "attach");
|
||||||
|
|
||||||
|
if (oc == null)//如果不存在
|
||||||
|
{
|
||||||
|
oc = new OtherConfig();
|
||||||
|
oc.ConfigName = "attach";
|
||||||
|
oc.ConfigValue = json;
|
||||||
|
oc.LastUpdateTime = DateTime.Now;
|
||||||
|
oc.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oc.ConfigValue = json;
|
||||||
|
oc.LastUpdateTime = DateTime.Now;
|
||||||
|
oc.Update();
|
||||||
|
}
|
||||||
|
Admin.WriteLogActions("修改附件配置;");
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Message = "修改附件配置成功";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region robots设置
|
||||||
|
[HttpGet]
|
||||||
|
[MyAuthorize("view","robots" )]
|
||||||
|
public IActionResult Robots()
|
||||||
|
{
|
||||||
|
//获取文件内容
|
||||||
|
string file = Path.Combine(_env.WebRootPath, "robots.txt");
|
||||||
|
string content = "";
|
||||||
|
if (System.IO.File.Exists(file))
|
||||||
|
{
|
||||||
|
content = System.IO.File.ReadAllText(file);
|
||||||
|
}
|
||||||
|
ViewBag.content = content;
|
||||||
|
Admin.WriteLogActions("查看Robots.txt;");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("edit", "robots", "JSON")]
|
||||||
|
public IActionResult Robots(string content)
|
||||||
|
{
|
||||||
|
string file = Path.Combine(_env.WebRootPath, "robots.txt");
|
||||||
|
if (System.IO.File.Exists(file))
|
||||||
|
{
|
||||||
|
//写入覆盖
|
||||||
|
System.IO.File.WriteAllText(file, content);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.IO.File.WriteAllText(file, content);
|
||||||
|
}
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Message = "修改Robots.txt成功";
|
||||||
|
Admin.WriteLogActions("修改Robots.txt成功;");
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
@model COMCMS.Core.Models.AttachConfigEntity
|
||||||
|
@{
|
||||||
|
ViewBag.title = "编辑网站附件设置";
|
||||||
|
}
|
||||||
|
<div class="wrapper wrapper-content">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div class="ibox-title">
|
||||||
|
<h5>@ViewBag.Title</h5>
|
||||||
|
<div class="ibox-tools">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ibox-content">
|
||||||
|
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editAttachConfigForm", @class = "form-horizontal m-t" }))
|
||||||
|
{
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">重命名文件名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select class="form-control" asp-for="IsRandomFileName">
|
||||||
|
<option value="0" >不重命名</option>
|
||||||
|
<option value="1" >随机重命名</option>
|
||||||
|
<option value="2" >日期重命名</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">图片最大尺寸:</label>
|
||||||
|
<div class="col-sm-8 form-inline">
|
||||||
|
<input type="number" placeholder="请输入图片最大宽度" name="ImgMaxWidth" id="ImgMaxWidth" class="form-control" value="@Model.ImgMaxWidth">
|
||||||
|
X
|
||||||
|
<input type="number" placeholder="请输入图片最大高度" name="ImgMaxHeight" id="ImgMaxHeight" class="form-control" value="@Model.ImgMaxHeight">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">缩略图:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<label class="checkbox-inline i-checks">
|
||||||
|
<input type="checkbox" value="1" name="IsCreateThum" id="IsCreateThum" @(Model.IsCreateThum == 1 ? "checked = \"checked\"" : "")> 图片生成缩略图
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">缩略图质量:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="ThumQty" name="ThumQty" maxlength="3" type="number" max="100" class="form-control" required aria-required="true" placeholder="设置图片附件缩略图的质量参数,范围为 0~100 的整数,数值越大结果图片效果越好,但尺寸也越大" value="@Model.ThumQty">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">缩略图大小:</label>
|
||||||
|
<div class="col-sm-8 form-inline">
|
||||||
|
<input type="number" placeholder="请输入缩略图宽度" name="ThumMaxWidth" id="ThumMaxWidth" class="form-control" value="@Model.ThumMaxWidth">
|
||||||
|
X
|
||||||
|
<input type="number" placeholder="请输入缩略图高度" name="ThumMaxHeight" id="ThumMaxHeight" class="form-control" value="@Model.ThumMaxHeight">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">开启水印功能:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<label class="checkbox-inline i-checks">
|
||||||
|
<input type="checkbox" value="1" name="IsWaterMark" id="IsWaterMark" @(Model.IsWaterMark == 1 ? "checked = \"checked\"" : "")> 图片自动加上水印 (勾选则上传图片将自动加上水印)
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">水印图片质量:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="WaterMarkQty" name="WaterMarkQty" maxlength="3" type="number" max="100" class="form-control" required aria-required="true" placeholder="加水印图片质量,范围为 0~100 的整数,数值越大结果图片效果越好,但尺寸也越大" value="@Model.WaterMarkQty">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">水印文件:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="WaterMarkImg" type="text" class="form-control upload-path" name="WaterMarkImg" value="@Model.WaterMarkImg" placeholder="水印文件,只支持jpg、png" aria-required="true">
|
||||||
|
<span class="input-group-addon my-upload-span upload-img"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">水印透明度:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="WaterMarkQty" name="WaterMarkQty" maxlength="3" type="number" max="100" class="form-control" required aria-required="true" placeholder="水印透明度,范围为 0~100 的整数" value="@Model.WaterMarkDiaphaneity">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">水印位置:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<p>
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="radio" value="1" name="WaterMarkPlace" id="WaterMarkPlace_1">1
|
||||||
|
</label>
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="radio" value="2" name="WaterMarkPlace" id="WaterMarkPlace_2">2
|
||||||
|
</label>
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="radio" value="3" name="WaterMarkPlace" id="WaterMarkPlace_3">3
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="radio" value="4" name="WaterMarkPlace" id="WaterMarkPlace_4">4
|
||||||
|
</label>
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="radio" value="5" name="WaterMarkPlace" id="WaterMarkPlace_5">5
|
||||||
|
</label>
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="radio" value="6" name="WaterMarkPlace" id="WaterMarkPlace_6">6
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="radio" value="7" name="WaterMarkPlace" id="WaterMarkPlace_7">7
|
||||||
|
</label>
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="radio" value="8" name="WaterMarkPlace" id="WaterMarkPlace_8">8
|
||||||
|
</label>
|
||||||
|
<label class="checkbox-inline">
|
||||||
|
<input type="radio" value="9" name="WaterMarkPlace" id="WaterMarkPlace_9">9
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<script>
|
||||||
|
$("#WaterMarkPlace_@Model.WaterMarkPlace").prop("checked", "checked");
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-4 col-sm-offset-3">
|
||||||
|
<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 提交 </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
//加载上传
|
||||||
|
$(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp", notwater: true });
|
||||||
|
DoPost("editAttachConfigForm");
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
@{
|
||||||
|
ViewBag.title = "查看/编辑Robots配置";
|
||||||
|
}
|
||||||
|
<div class="wrapper wrapper-content">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div class="ibox-title">
|
||||||
|
<h5>@ViewBag.Title</h5>
|
||||||
|
<div class="ibox-tools">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ibox-content">
|
||||||
|
<form asp-area="AdminCP" asp-controller="System" asp-action="Robots" name="editRobotsConfigForm" id="editRobotsConfigForm" class="form-horizontal m-t" method="post">
|
||||||
|
<div class="alert alert-info alert-dismissable">
|
||||||
|
<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
|
||||||
|
<p>注意:本选项仅供<b>专业人士</b>使用,请不要擅自修改,否则,网站将可能正常被搜索引擎收录!</p>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">内容:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<textarea id="content" name="content" class="form-control" rows="10" placeholder="您可以填写Robots内容">@ViewBag.content</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-4 col-sm-offset-3">
|
||||||
|
<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 提交 </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
DoPost("editRobotsConfigForm");
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
@model COMCMS.Core.Models.SMTPConfigEntity
|
||||||
|
@{
|
||||||
|
ViewBag.title = "编辑网站SMTP设置";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="wrapper wrapper-content">
|
||||||
|
<div class="row">
|
||||||
|
<div class="tabs-container">
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<li class="active">
|
||||||
|
<a data-toggle="tab" href="#tab-1" aria-expanded="true"> SMTP基本设置</a>
|
||||||
|
</li>
|
||||||
|
<li class="">
|
||||||
|
<a data-toggle="tab" href="#tab-2" aria-expanded="false"> 发送邮件测试</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div id="tab-1" class="tab-pane active">
|
||||||
|
<div class="panel-body">
|
||||||
|
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editBaseConfigForm", @class = "form-horizontal m-t" }))
|
||||||
|
{
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">SMTP服务器:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="SmtpHost" name="SmtpHost" minlength="2" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="设置 SMTP 服务器的地址" value="@Model.SmtpHost">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">SMTP 端口:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="SmtpProt" name="SmtpProt" maxlength="5" type="number" class="form-control" placeholder="设置 SMTP 服务器的端口,默认为 25" value="@Model.SmtpProt">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">发信人邮件地址:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="PostUserName" name="PostUserName" maxlength="250" type="text" class="form-control" placeholder="如果需要验证, 必须为本服务器的邮件地址。邮件地址中如果要包含用户名,格式为“username <user@domain.com>”" value="@Model.PostUserName">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">SMTP 身份验证用户名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="SmtpEmail" name="SmtpEmail" maxlength="100" type="text" class="form-control" placeholder="支持SMTP的Email帐号" value="@Model.SmtpEmail">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">公司电话:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="SmtpEmailPwd" name="SmtpEmailPwd" maxlength="50" type="text" class="form-control" placeholder="帐号密码" value="@Model.SmtpEmailPwd">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-4 col-sm-offset-2">
|
||||||
|
<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 提交 </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="tab-2" class="tab-pane">
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">测试收件人:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="txtEmail" name="txtEmail" maxlength="200" type="text" class="form-control" placeholder="请输入一个接收邮箱地址进行测试" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="hr-line-dashed"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-4 col-sm-offset-2">
|
||||||
|
<button class="btn btn-primary" type="button" onclick="alert('敬请期待...')"><i class="fa fa-send"></i> 测试发信 </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
DoPost("editBaseConfigForm");
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Diagnostics;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace COMCMS.Web.Controllers
|
||||||
|
{
|
||||||
|
public class StatusCodeController : Controller
|
||||||
|
{
|
||||||
|
[HttpGet("/StatusCode/{statusCode}")]
|
||||||
|
public IActionResult Index(int statusCode)
|
||||||
|
{
|
||||||
|
var reExecute = HttpContext.Features.Get<IStatusCodeReExecuteFeature>();
|
||||||
|
NewLife.Log.XTrace.WriteLine($"Unexpected Status Code: {statusCode}, OriginalPath: {reExecute.OriginalPath}");
|
||||||
|
ViewBag.url = "";
|
||||||
|
return View(statusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,6 +68,8 @@ namespace COMCMS.Web
|
|||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Home/Error");
|
app.UseExceptionHandler("/Home/Error");
|
||||||
}
|
}
|
||||||
|
//其他错误页面处理
|
||||||
|
app.UseStatusCodePagesWithReExecute("/StatusCode/{0}");
|
||||||
//启用Session
|
//启用Session
|
||||||
app.UseSession();
|
app.UseSession();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
@model int
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Error";
|
||||||
|
Layout = null;
|
||||||
|
}
|
||||||
|
@{
|
||||||
|
var statusCode = Model;
|
||||||
|
var statusmessage = "";
|
||||||
|
var tipmessage = "服务器好像出开了个小差...";
|
||||||
|
switch (statusCode)
|
||||||
|
{
|
||||||
|
case 400:
|
||||||
|
statusmessage = "Bad request: The request cannot be fulfilled due to bad syntax";
|
||||||
|
break;
|
||||||
|
case 403:
|
||||||
|
statusmessage = "Forbidden";
|
||||||
|
break;
|
||||||
|
case 404:
|
||||||
|
statusmessage = "系统找不到本页面";
|
||||||
|
tipmessage = "您所访问的页面好像被吃了...";
|
||||||
|
break;
|
||||||
|
case 408:
|
||||||
|
statusmessage = "The server timed out waiting for the request";
|
||||||
|
break;
|
||||||
|
case 500:
|
||||||
|
statusmessage = "Internal Server Error - server was unable to finish processing the request";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
statusmessage = "That's odd... Something we didn't expect happened";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>@(Model)错误</title>
|
||||||
|
<link href="~/lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||||
|
<link href="~/hplus/css/font-awesome.min.css" rel="stylesheet" />
|
||||||
|
<link href="~/hplus/css/style.css" rel="stylesheet" />
|
||||||
|
<link href="~/css/animate.min.css" rel="stylesheet" />
|
||||||
|
<base target="_blank">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="middle-box text-center animated fadeInDown">
|
||||||
|
<h1>@Model</h1>
|
||||||
|
<h3 class="font-bold">@statusmessage</h3>
|
||||||
|
<div class="error-desc">
|
||||||
|
@(tipmessage)
|
||||||
|
<br />
|
||||||
|
当前页面:@ViewBag.url
|
||||||
|
<br />您可以返回主页看看
|
||||||
|
<br /><a href="/" class="btn btn-primary m-t">返回</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- js -->
|
||||||
|
<environment names="Development">
|
||||||
|
<script src="~/lib/jquery/dist/jquery.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
|
||||||
|
</environment>
|
||||||
|
<environment names="Staging,Production">
|
||||||
|
<script src="~/lib/jquery/dist/jquery.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
|
||||||
|
</environment>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user