[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class PageParser : TemplateControlParser
{
- bool enableSessionState = true;
+ PagesEnableSessionState enableSessionState = PagesEnableSessionState.True;
bool enableViewStateMac = true;
- bool smartNavigation = false;
+ bool smartNavigation;
bool haveTrace;
bool trace;
bool notBuffer;
- TraceMode tracemode;
- bool readonlySessionState = false;
+ TraceMode tracemode = TraceMode.Default;
string responseEncoding;
string contentType;
int codepage = -1;
string errorPage;
bool validateRequest;
string clientTarget;
- Type baseType = typeof (Page);
#if NET_2_0
+ bool async;
+ int asyncTimeout = -1;
string masterPage;
Type masterType;
string title;
public PageParser ()
{
- LoadPagesConfigDefaults ();
+ LoadConfigDefaults ();
}
internal PageParser (string virtualPath, string inputFile, HttpContext context)
Context = context;
BaseVirtualDir = UrlUtils.GetDirectory (virtualPath);
InputFile = inputFile;
- SetBaseType (PagesConfig.PageBaseType);
+ SetBaseType (null);
AddApplicationAssembly ();
- LoadPagesConfigDefaults ();
+ LoadConfigDefaults ();
+#if NET_2_0
+ this.VirtualPath = new VirtualPath (virtualPath);
+#endif
}
#if NET_2_0
internal PageParser (string virtualPath, TextReader reader, HttpContext context)
+ : this (virtualPath, null, reader, context)
+ {
+ }
+
+ internal PageParser (string virtualPath, string inputFile, TextReader reader, HttpContext context)
{
Context = context;
BaseVirtualDir = UrlUtils.GetDirectory (virtualPath);
Reader = reader;
- SetBaseType (PagesConfig.PageBaseType);
+ if (String.IsNullOrEmpty (inputFile)) {
+ HttpRequest req = context != null ? context.Request : null;
+ if (req != null)
+ InputFile = req.MapPath (virtualPath);
+ } else
+ InputFile = inputFile;
+ SetBaseType (null);
AddApplicationAssembly ();
- LoadPagesConfigDefaults ();
+ LoadConfigDefaults ();
+#if NET_2_0
+ this.VirtualPath = new VirtualPath (virtualPath);
+#endif
}
#endif
- internal override void LoadPagesConfigDefaults ()
+ internal override void LoadConfigDefaults ()
{
- base.LoadPagesConfigDefaults ();
+ base.LoadConfigDefaults ();
#if NET_2_0
PagesSection ps = PagesConfig;
#else
PagesConfiguration ps = PagesConfig;
-#endif
+#endif
notBuffer = !ps.Buffer;
-#if NET_2_0
- switch (ps.EnableSessionState) {
- case PagesEnableSessionState.True:
- enableSessionState = true;
- break;
-
- case PagesEnableSessionState.ReadOnly:
- enableSessionState = true;
- readonlySessionState = true;
- break;
-
- default:
- enableSessionState = false;
- break;
- }
-#else
- if (String.Compare (ps.EnableSessionState, "true", true, CultureInfo.InvariantCulture) == 0)
- enableSessionState = true;
- else
- enableSessionState = false;
-#endif
-
+ enableSessionState = ps.EnableSessionState;
enableViewStateMac = ps.EnableViewStateMac;
smartNavigation = ps.SmartNavigation;
validateRequest = ps.ValidateRequest;
string inputFile,
HttpContext context)
{
+#if NET_2_0
+ return BuildManager.CreateInstanceFromVirtualPath (virtualPath, typeof (IHttpHandler)) as IHttpHandler;
+#else
PageParser pp = new PageParser (virtualPath, inputFile, context);
IHttpHandler h = (IHttpHandler) pp.GetCompiledInstance ();
return h;
+#endif
}
internal override void ProcessMainAttributes (Hashtable atts)
{
- // note: if EnableSessionState is not specified in page directive
- // then we must use LoadPagesConfigDefaults settings
- if (atts.ContainsKey("EnableSessionState")) {
- // note: the 'enableSessionState' configuration property is
- // processed in a case-sensitive manner while the page-level
- // attribute is processed case-insensitive
- string enabless = GetString (atts, "EnableSessionState", enableSessionState.ToString ());
- if (enabless != null) {
- readonlySessionState = (String.Compare (enabless, "readonly", true) == 0);
- if (readonlySessionState == true || String.Compare (enabless, "true", true) == 0) {
- enableSessionState = true;
- } else if (String.Compare (enabless, "false", true) == 0) {
- enableSessionState = false;
- } else {
- ThrowParseException ("Invalid value for enableSessionState: " + enabless);
- }
- }
- }
+ // note: the 'enableSessionState' configuration property is
+ // processed in a case-sensitive manner while the page-level
+ // attribute is processed case-insensitive
+ string enabless = GetString (atts, "EnableSessionState", null);
+ if (enabless != null) {
+ if (String.Compare (enabless, "readonly", true) == 0)
+ enableSessionState = PagesEnableSessionState.ReadOnly;
+ else if (String.Compare (enabless, "true", true) == 0)
+ enableSessionState = PagesEnableSessionState.True;
+ else if (String.Compare (enabless, "false", true) == 0)
+ enableSessionState = PagesEnableSessionState.False;
+ else
+ ThrowParseException ("Invalid value for enableSessionState: " + enabless);
+ }
string cp = GetString (atts, "CodePage", null);
if (cp != null) {
if (responseEncoding != null)
ThrowParseException ("CodePage and ResponseEncoding are " +
- "mutually exclusive.");
+ "mutually exclusive.");
int codepage = 0;
try {
notBuffer = !GetBool (atts, "Buffer", true);
#if NET_2_0
+ async = GetBool (atts, "Async", false);
+ string asyncTimeoutVal = GetString (atts, "AsyncTimeout", null);
+ if (asyncTimeoutVal != null) {
+ try {
+ asyncTimeout = Int32.Parse (asyncTimeoutVal);
+ } catch (Exception) {
+ ThrowParseException ("AsyncTimeout must be an integer value");
+ }
+ }
+
masterPage = GetString (atts, "MasterPageFile", masterPage);
// Make sure the page exists
- if (!String.IsNullOrEmpty (masterPage))
- MasterPageParser.GetCompiledMasterType (masterPage, MapPath (masterPage), HttpContext.Current);
-
+ if (!String.IsNullOrEmpty (masterPage)) {
+ BuildManager.GetCompiledType (masterPage);
+ AddDependency (masterPage);
+ }
+
title = GetString(atts, "Title", null);
theme = GetString (atts, "Theme", theme);
styleSheetTheme = GetString (atts, "StyleSheetTheme", styleSheetTheme);
- enable_event_validation = GetBool (atts, "EnableEventValidation", true);
+ enable_event_validation = GetBool (atts, "EnableEventValidation", enable_event_validation);
maintainScrollPositionOnPostBack = GetBool (atts, "MaintainScrollPositionOnPostBack", maintainScrollPositionOnPostBack);
#endif
// Ignored by now
} else if (virtualPath != null) {
string mappedPath = MapPath (virtualPath);
if (isMasterType)
- type = masterType = MasterPageParser.GetCompiledMasterType (virtualPath,
- mappedPath,
- HttpContext.Current);
+ type = masterType = BuildManager.GetCompiledType (virtualPath);
else
type = previousPageType = GetCompiledPageType (virtualPath, mappedPath,
HttpContext.Current);
public static Type GetCompiledPageType (string virtualPath, string inputFile, HttpContext context)
{
+#if NET_2_0
+ return BuildManager.GetCompiledType (virtualPath);
+#else
PageParser pp = new PageParser (virtualPath, inputFile, context);
return pp.CompileIntoType ();
+#endif
}
protected override Type CompileIntoType ()
}
internal bool EnableSessionState {
- get { return enableSessionState; }
+ get {
+ return enableSessionState == PagesEnableSessionState.True ||
+ ReadOnlySessionState;
+ }
}
internal bool EnableViewStateMac {
}
internal bool ReadOnlySessionState {
- get { return readonlySessionState; }
+ get {
+ return enableSessionState == PagesEnableSessionState.ReadOnly;
+ }
}
internal bool HaveTrace {
internal TraceMode TraceMode {
get { return tracemode; }
- }
-
- internal override Type DefaultBaseType {
- get { return baseType; }
- }
+ }
+#if NET_2_0
+ internal override string DefaultBaseTypeName {
+ get { return PagesConfig.PageBaseType; }
+ }
+#else
internal override string DefaultBaseTypeName {
get { return "System.Web.UI.Page"; }
}
-
+#endif
+
internal override string DefaultDirectiveName {
get { return "page"; }
}
}
#if NET_2_0
+ internal bool Async {
+ get { return async; }
+ }
+
+ internal int AsyncTimeout {
+ get { return asyncTimeout; }
+ }
+
internal string Theme {
get { return theme; }
}