public override bool FileExists(string virtualPath)
        {
            if (DomainServiceVirtualPathProvider.OwnsFile(virtualPath))
            {
                return(true);
            }

            return(base.FileExists(virtualPath));
        }
        public override string GetCacheKey(string virtualPath)
        {
            if (DomainServiceVirtualPathProvider.OwnsFile(virtualPath))
            {
                // We were able to provide the file, so we're responsible for returning a cache key.
                return(virtualPath);
            }

            return(base.GetCacheKey(virtualPath));
        }
        public override VirtualFile GetFile(string virtualPath)
        {
            KeyValuePair <string, Type> domainServiceEntry;

            if (DomainServiceVirtualPathProvider.OwnsFile(virtualPath, out domainServiceEntry))
            {
                return(new DomainServiceVirtualFile(domainServiceEntry.Value, virtualPath));
            }

            return(base.GetFile(virtualPath));
        }
        public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
        {
            if (DomainServiceVirtualPathProvider.OwnsFile(virtualPath))
            {
                // Return a no-op cache dependency such that ASP.NET doesn't create a FileSystemWatcher
                // to listen for changes to this file.
                return(new DomainServiceCacheDependency());
            }

            return(base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart));
        }
 public static void Register()
 {
     if (DomainServiceVirtualPathProvider.vppRegistered == false)
     {
         lock (DomainServiceVirtualPathProvider.vppRegistrationLock)
         {
             if (DomainServiceVirtualPathProvider.vppRegistered == false)
             {
                 DomainServiceVirtualPathProvider.EnsureDomainServiceTypes();
                 HostingEnvironment.RegisterVirtualPathProvider(new DomainServiceVirtualPathProvider());
                 DomainServiceVirtualPathProvider.vppRegistered = true;
             }
         }
     }
 }
Example #6
0
        private static void ApplicationBeginRequest(object sender, EventArgs e)
        {
            HttpRequest request     = HttpContext.Current.Request;
            string      virtualPath = request.AppRelativeCurrentExecutionFilePath;

            // Rewrite /ClientBin/Northwind.svc to /Northwind.svc. This way we guarantee we
            // only instantiate a single service host, and we allow someone to think about
            // a single file (e.g. when defining ACLs, etc.).
            KeyValuePair <string, Type> domainServiceEntry;

            if (DomainServiceVirtualPathProvider.ShouldRewritePath(virtualPath, out domainServiceEntry))
            {
                string queryString = request.QueryString.ToString();
                HttpContext.Current.RewritePath(
                    DomainServiceVirtualPathProvider.DomainServicesDirectory + domainServiceEntry.Key,
                    request.PathInfo,
                    queryString,
                    /* setClientFilePath */ true);
            }
        }
Example #7
0
 void IHttpModule.Init(HttpApplication application)
 {
     application.BeginRequest += new EventHandler(DomainServiceHttpModule.ApplicationBeginRequest);
     DomainServiceVirtualPathProvider.Register();
 }