+2008-04-01 Marek Habersack <mhabersack@novell.com>
+
+ * HostingEnvironment.cs: initialize custom VPP on
+ registration.
+ Added an internal boolena property to signal if we're using a
+ custom VPP or not (HaveCustomVPP)
+
+2008-03-31 Marek Habersack <mhabersack@novell.com>
+
+ * VirtualPathProvider.cs: internal SetPrevious method renamed to
+ InitializeAndSetPrevious.
+
2008-03-27 Marek Habersack <mhabersack@novell.com>
* DefaultVirtualPathProvider.cs: support relative virtual paths in
new DefaultVirtualPathProvider ();
static int busy_count;
+ internal static bool HaveCustomVPP {
+ get;
+ private set;
+ }
+
public HostingEnvironment ()
{
// The documentation says that this is called once per domain by the ApplicationManager and
if (virtualPathProvider == null)
throw new ArgumentNullException ("virtualPathProvider");
- virtualPathProvider.SetPrevious (vpath_provider);
+ VirtualPathProvider previous = vpath_provider;
vpath_provider = virtualPathProvider;
+ vpath_provider.InitializeAndSetPrevious (previous);
+ if (!(virtualPathProvider is DefaultVirtualPathProvider))
+ HaveCustomVPP = true;
+ else
+ HaveCustomVPP = false;
}
public static IDisposable SetCultures (string virtualPath)
{
}
- internal void SetPrevious (VirtualPathProvider prev)
- {
- this.prev = prev;
- }
-
protected internal VirtualPathProvider Previous {
get { return prev; }
}
{
}
+ internal void InitializeAndSetPrevious (VirtualPathProvider prev)
+ {
+ Console.WriteLine ("{0}.InitializeAndSetPrevious ({1})", this, prev);
+ this.prev = prev;
+ Console.WriteLine ("\tprevious chain:");
+
+ VirtualPathProvider p = this.prev;
+ while (p != null) {
+ Console.WriteLine ("\t\t{0}", p);
+ p = p.Previous;
+ }
+
+ Initialize ();
+ }
+
public virtual string CombineVirtualPaths (string basePath, string relativePath)
{
return VirtualPathUtility.Combine (basePath, relativePath);
+2008-03-31 Marek Habersack <mhabersack@novell.com>
+
+ * StaticFileHandler.cs: added code to use custom
+ VirtualPathProvider, if present, to serve files from virtual
+ storage.
+
+ * HttpResponse.cs: added two internal TransmitFile overloads which
+ take a VirtualFile as a parameter.
+
2008-03-27 Marek Habersack <mhabersack@novell.com>
* HttpRequest.cs: make UrlComponents internal.
using System.Web.Configuration;
using System.Globalization;
using System.Security.Permissions;
+using System.Web.Hosting;
namespace System.Web {
output_stream.ApplyFilter (final_flush);
Flush (final_flush);
}
-
+#if NET_2_0
+ internal void TransmitFile (VirtualFile vf)
+ {
+ TransmitFile (vf, false);
+ }
+
+ internal void TransmitFile (VirtualFile vf, bool final_flush)
+ {
+ if (vf == null)
+ throw new ArgumentNullException ("vf");
+
+ using (Stream s = vf.Open ()) {
+ long len = s.Length;
+ byte[] buf = new byte [len];
+ int readBytes = s.Read (buf, 0, (int) len);
+ output_stream.Write (buf, 0, readBytes);
+ output_stream.ApplyFilter (final_flush);
+ Flush (final_flush);
+ }
+ }
+#endif
+
#region Session state support
internal void SetAppPathModifier (string app_modifier)
{
using System.Globalization;
using System.IO;
using System.Web.Util;
+using System.Web.Hosting;
namespace System.Web
{
{
HttpRequest request = context.Request;
HttpResponse response = context.Response;
+
+#if NET_2_0
+ if (HostingEnvironment.HaveCustomVPP) {
+ VirtualFile vf = null;
+ VirtualPathProvider vpp = HostingEnvironment.VirtualPathProvider;
+ string vpath = request.FilePath;
+
+ if (vpp.FileExists (vpath))
+ vf = vpp.GetFile (vpath);
+
+ if (vf == null)
+ throw new HttpException (404, "Path '" + vpath + "' was not found.", vpath);
+
+ response.ContentType = MimeTypes.GetMimeType (vpath);
+ response.TransmitFile (vf);
+ return;
+ }
+#endif
+
string fileName = request.PhysicalPath;
FileInfo fi = new FileInfo (fileName);
if (!fi.Exists || !ValidFileName (fileName))
response.Redirect (request.Path + '/');
return;
}
-
+
string strHeader = request.Headers ["If-Modified-Since"];
try {
if (strHeader != null) {
try {
DateTime lastWT = fi.LastWriteTime.ToUniversalTime ();
response.AddHeader ("Last-Modified", lastWT.ToString ("r"));
-
response.ContentType = MimeTypes.GetMimeType (fileName);
response.TransmitFile (fileName, true);
} catch (Exception) {