//
//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
using System.Collections.Specialized;
using System.Security.Permissions;
using System.Text;
+using System.Threading;
using System.Web.Configuration;
using System.Web.SessionState;
-namespace System.Web {
-
+namespace System.Web
+{
//
// Methods exposed through HttpContext.Server property
//
Execute (path, writer, true);
}
-#if NET_2_0
public void Execute (string path, bool preserveForm)
{
Execute (path, null, preserveForm);
}
-#endif
-
-#if NET_2_0
- public
-#else
- internal
-#endif
- void Execute (string path, TextWriter writer, bool preserveForm)
+
+ public void Execute (string path, TextWriter writer, bool preserveForm)
{
Execute (path, writer, preserveForm, false);
}
string exePath = UrlUtils.Combine (context.Request.BaseVirtualDir, path);
bool cookieless = false;
-
-#if NET_2_0
- SessionStateSection config = WebConfigurationManager.GetSection ("system.web/sessionState") as SessionStateSection;
+ SessionStateSection config = WebConfigurationManager.GetWebApplicationSection ("system.web/sessionState") as SessionStateSection;
cookieless = SessionStateModule.IsCookieLess (context, config);
-#else
- SessionConfig config = HttpContext.GetAppConfig ("system.web/sessionState") as SessionConfig;
- cookieless = config.CookieLess;
-#endif
+
if (cookieless)
exePath = UrlUtils.RemoveSessionId (VirtualPathUtility.GetDirectory (exePath), exePath);
Execute (handler, writer, preserveForm, exePath, queryString, isTransfer, true);
}
- internal void Execute (IHttpHandler handler, TextWriter writer, bool preserveForm, string exePath, string queryString, bool isTransfer, bool isInclude) {
-#if NET_2_0 && !TARGET_J2EE
+ internal void Execute (IHttpHandler handler, TextWriter writer, bool preserveForm, string exePath, string queryString, bool isTransfer, bool isInclude)
+ {
// If the target handler is not Page, the transfer must not occur.
// InTransit == true means we're being called from Transfer
- if (isTransfer && !(handler is Page))
- throw new HttpException ("Transfer is possible only to .aspx files");
-#endif
+ bool is_static = (handler is StaticFileHandler);
+ if (isTransfer && !(handler is Page) && !is_static)
+ throw new HttpException ("Transfer is only allowed to .aspx and static files");
HttpRequest request = context.Request;
string oldQuery = request.QueryStringRaw;
string oldExePath = request.CurrentExecutionFilePath;
bool oldIsInclude = context.IsProcessingInclude;
try {
-#if NET_2_0
context.PushHandler (handler);
-#endif
+ if (is_static) // Not sure if this should apply to Page too
+ request.SetFilePath (exePath);
+
request.SetCurrentExePath (exePath);
context.IsProcessingInclude = isInclude;
} else {
IHttpAsyncHandler asyncHandler = (IHttpAsyncHandler) handler;
IAsyncResult ar = asyncHandler.BeginProcessRequest (context, null, null);
- ar.AsyncWaitHandle.WaitOne ();
+ WaitHandle asyncWaitHandle = ar != null ? ar.AsyncWaitHandle : null;
+ if (asyncWaitHandle != null)
+ asyncWaitHandle.WaitOne ();
asyncHandler.EndProcessRequest (ar);
}
} finally {
response.SetTextWriter (previous);
if (!preserveForm)
request.SetForm (oldForm);
-#if NET_2_0
+
context.PopHandler ();
-#endif
request.SetCurrentExePath (oldExePath);
context.IsProcessingInclude = oldIsInclude;
}
return context.Request.MapPath (path);
}
+
+ public void TransferRequest (string path)
+ {
+ TransferRequest (path, false, null, null);
+ }
+
+ public void TransferRequest (string path, bool preserveForm)
+ {
+ TransferRequest (path, preserveForm, null, null);
+ }
+
+ [MonoTODO ("Always throws PlatformNotSupportedException.")]
+ public void TransferRequest (string path, bool preserveForm, string method, NameValueCollection headers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
public void Transfer (string path)
{
Transfer (path, true);
Execute (path, null, preserveForm, true);
context.Response.End ();
}
-#if NET_2_0
+
public void Transfer (IHttpHandler handler, bool preserveForm)
{
if (handler == null)
}
return new string (chars);
}
-#endif
public string UrlDecode (string s)
{