<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Model.Sys_Controllers>>" Theme="base" %>
<script runat="server"> void Page_PreInit() { string t = "";
if (Request.Cookies[User.Identity.Name "Theme"] != null) { t = Request.Cookies[User.Identity.Name "Theme"].Value; }
if (Request.QueryString["Theme"] != null) { t = Request.QueryString["Theme"]; }
if (!string.IsNullOrEmpty(t)) { Response.Cookies[User.Identity.Name "Theme"].Value = t; Response.Cookies[User.Identity.Name "Theme"].Expires = DateTime.Now.AddMonths(1); this.Page.Theme = t; } } </script>
不是不支持Init ,是因为mvc的管道跟webform的有区别 http://topic.csdn.net/u/20110222/10/bccbe025-2bcc-4e74-bc0d-20a5fcc066ed.html
你这段代码属于逻辑代码,应该放在Controller中,razor模板是用来显示用的,不应该放这些逻辑代码