Exemplo n.º 1
0
    private static string GetFileUrlPrefix(string fileSystemName, bool isDownload)
    {
        var routeName = isDownload ? "VfsFileDownloadUrl" : "VfsFileUrl";

        if (RouteTable.Routes[routeName] != null)
        {
            var virtualPath = ControlExtensions.GetRouteUrl(routeName, new Hashtable()
            {
                { "filesystem", fileSystemName }
            });
            if (virtualPath == null)
            {
                throw new Exception("Invalid configuration for route " + routeName);
            }
            var basePath = VirtualPathUtility.AppendTrailingSlash(WebManager.BasePath);
            if (virtualPath.StartsWith(basePath))
            {
                virtualPath = virtualPath.Substring(basePath.Length);
            }
            int paramStart = virtualPath.IndexOf('?');
            return((paramStart >= 0 ? virtualPath.Substring(0, paramStart) : virtualPath) + "?");
        }
        return(isDownload ?
               String.Format("FileTreeAjaxHandler.axd?filesystem={0}&action=download&file=", fileSystemName) :
               String.Format("FileTreeAjaxHandler.axd?filesystem={0}&file=", fileSystemName));
    }
Exemplo n.º 2
0
 public static string GetRouteUrlSafe(Control ctrl, string routeName, IDictionary context)
 {
     try {
         return(ControlExtensions.GetRouteUrl(ctrl, routeName, context));
     } catch (Exception ex) {
         log.Write(LogEvent.Debug, ex);
         return(null);
     }
 }