net_beian/Controllers/BaseController.cs

(完整代码) 1KB

using System.Configuration;
using System.Web.Mvc;

namespace net_beian.Controllers
{
    public class BaseController : Controller
    {
        private readonly string _titleFormat ="{0}-"+ConfigurationManager.AppSettings["WebName"];

        protected string Title { get; set; }

        public string Keywords { set; get; }

        public string Description { set; get; }

        public BaseController()
        {
            Title = ConfigurationManager.AppSettings["Title"];
            Keywords = ConfigurationManager.AppSettings["Keyword"];
            Description = ConfigurationManager.AppSettings["Description"];
        }

        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            #region -----设置标题、关键字、网站描述-----
            if (string.IsNullOrWhiteSpace(Title))
            {
                ViewData["Title"] = ConfigurationManager.AppSettings["WebName"];
            }
            else
            {
                ViewData["Title"] = string.Format(_titleFormat, Title);
            }
            ViewData["Description"] = Description;
            ViewData["Keywords"] = Keywords;
            #endregion

            base.OnActionExecuted(filterContext);
        }

    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。