BootstrapAdmin/Bootstrap.Admin/Controllers/HomeController.cs

42 lines
1.3 KiB
C#
Raw Normal View History

2016-10-21 16:35:26 +08:00
using Bootstrap.Admin.Models;
using Bootstrap.DataAccess;
using Microsoft.AspNetCore.Authentication.Cookies;
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>
public IActionResult Index()
2016-10-20 17:55:29 +08:00
{
var model = new HeaderBarModel(User.Identity);
var url = DictHelper.RetrieveHomeUrl(model.AppCode);
return url.Equals("~/Home/Index", System.StringComparison.OrdinalIgnoreCase) ? (IActionResult)View(model) : Redirect(url);
2016-10-20 17:55:29 +08:00
}
/// <summary>
///
/// </summary>
2018-06-11 13:51:50 +08:00
/// <param name="id"></param>
/// <returns></returns>
[AllowAnonymous]
2018-06-11 13:51:50 +08:00
public IActionResult Error(int id)
{
var model = ErrorModel.CreateById(id);
if (id != 403)
{
var returnUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].ToString();
if (!string.IsNullOrEmpty(returnUrl)) model.ReturnUrl = returnUrl;
}
return View(model);
}
2016-10-20 17:55:29 +08:00
}
}