2016-10-21 16:35:26 +08:00
|
|
|
|
using Bootstrap.Admin.Models;
|
2016-10-23 15:46:18 +08:00
|
|
|
|
using Bootstrap.DataAccess;
|
2018-10-10 14:49:36 +08:00
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
2018-06-11 12:48:11 +08:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2018-06-07 00:45:47 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2016-10-20 17:55:29 +08:00
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Controllers
|
|
|
|
|
{
|
2016-10-21 16:35:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2016-10-20 17:55:29 +08:00
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
2016-10-21 16:35:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2018-09-16 01:24:51 +08:00
|
|
|
|
public IActionResult Index()
|
2016-10-20 17:55:29 +08:00
|
|
|
|
{
|
2018-09-16 01:24:51 +08:00
|
|
|
|
var url = DictHelper.RetrieveHomeUrl();
|
|
|
|
|
return url.Equals("~/Home/Index", System.StringComparison.OrdinalIgnoreCase) ? (IActionResult)View(new HeaderBarModel(User.Identity)) : Redirect(url);
|
2016-10-20 17:55:29 +08:00
|
|
|
|
}
|
2018-11-20 22:27:24 +08:00
|
|
|
|
|
2018-06-11 12:48:11 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2018-06-11 13:51:50 +08:00
|
|
|
|
/// <param name="id"></param>
|
2018-06-11 12:48:11 +08:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[AllowAnonymous]
|
2018-06-11 13:51:50 +08:00
|
|
|
|
public IActionResult Error(int id)
|
2018-06-11 12:48:11 +08:00
|
|
|
|
{
|
2018-10-12 18:52:28 +08:00
|
|
|
|
var returnUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].ToString();
|
2018-11-20 22:27:24 +08:00
|
|
|
|
var model = new ErrorModel() { ReturnUrl = string.IsNullOrEmpty(returnUrl) ? Url.Content("~/Home/Index") : returnUrl };
|
|
|
|
|
model.Title = "服务器内部错误";
|
|
|
|
|
model.Content = "服务器内部错误";
|
|
|
|
|
model.Image = "error_icon.png";
|
|
|
|
|
if (id == 0)
|
|
|
|
|
{
|
|
|
|
|
model.Content = "未处理服务器内部错误";
|
|
|
|
|
}
|
|
|
|
|
else if (id == 404)
|
|
|
|
|
{
|
|
|
|
|
model.Title = "资源未找到";
|
|
|
|
|
model.Content = "请求资源未找到";
|
|
|
|
|
model.Image = "404_icon.png";
|
|
|
|
|
}
|
|
|
|
|
return View(model);
|
2018-06-11 12:48:11 +08:00
|
|
|
|
}
|
2016-10-20 17:55:29 +08:00
|
|
|
|
}
|
|
|
|
|
}
|