当前位置: 首页>>代码示例>>C#>>正文


C# VirtualPath.FailIfNotWithinAppRoot方法代码示例

本文整理汇总了C#中System.Web.VirtualPath.FailIfNotWithinAppRoot方法的典型用法代码示例。如果您正苦于以下问题:C# VirtualPath.FailIfNotWithinAppRoot方法的具体用法?C# VirtualPath.FailIfNotWithinAppRoot怎么用?C# VirtualPath.FailIfNotWithinAppRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.VirtualPath的用法示例。


在下文中一共展示了VirtualPath.FailIfNotWithinAppRoot方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MapPath

        internal String MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, bool allowCrossAppMapping) {
            if (_wr == null)
                throw new HttpException(SR.GetString(SR.Cannot_map_path_without_context));

            // treat null as "."

            // 
            if (virtualPath == null)
                virtualPath = VirtualPath.Create(".");

            VirtualPath originalVirtualPath = virtualPath; // remember for patch-up at the end

            // Combine it with the base if one was passed in
            if (baseVirtualDir != null) {
                virtualPath = baseVirtualDir.Combine(virtualPath);
            }

            if (!allowCrossAppMapping)
                virtualPath.FailIfNotWithinAppRoot();

            string realPath = virtualPath.MapPathInternal();

            // patch up the result for Everett combatibility (VSWhidbey 319826)
            if (virtualPath.VirtualPathString == "/" &&
                originalVirtualPath.VirtualPathString != "/" &&
                !originalVirtualPath.HasTrailingSlash &&
                UrlPath.PathEndsWithExtraSlash(realPath)) {
                realPath = realPath.Substring(0, realPath.Length - 1);
            }

            InternalSecurityPermissions.PathDiscovery(realPath).Demand();
            return realPath;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:33,代码来源:HttpRequest.cs

示例2: RewritePath

        internal void RewritePath(VirtualPath filePath, VirtualPath pathInfo, String queryString, bool setClientFilePath) {
            EnsureHasNotTransitionedToWebSocket();

            if (filePath == null)
                throw new ArgumentNullException("filePath");

            // resolve relative path
            filePath = Request.FilePathObject.Combine(filePath);

            // disallow paths outside of app
            filePath.FailIfNotWithinAppRoot();

            // clear things that depend on path
            ConfigurationPath = null;

            // rewrite path on request
            Request.InternalRewritePath(filePath, pathInfo, queryString, setClientFilePath);
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:18,代码来源:HttpContext.cs

示例3: GetConfigDocument

        private XmlDocument GetConfigDocument() {
            if (_document != null)
                return _document;

            if (!_initialized) {
                throw new InvalidOperationException(
                    SR.GetString(SR.XmlSiteMapProvider_Not_Initialized));
            }

            // Do the error checking here
            if (_virtualPath == null) {
                throw new ArgumentException(
                    SR.GetString(SR.XmlSiteMapProvider_missing_siteMapFile, _siteMapFileAttribute));
            }

            if (!_virtualPath.Extension.Equals(_xmlSiteMapFileExtension, StringComparison.OrdinalIgnoreCase)) {
                throw new InvalidOperationException(
                    SR.GetString(SR.XmlSiteMapProvider_Invalid_Extension, _virtualPath));
            }

            _normalizedVirtualPath = _virtualPath.CombineWithAppRoot();
            _normalizedVirtualPath.FailIfNotWithinAppRoot();

            // Make sure the file exists
            CheckSiteMapFileExists();

            _parentSiteMapFileCollection = new StringCollection();
            XmlSiteMapProvider xmlParentProvider = ParentProvider as XmlSiteMapProvider;
            if (xmlParentProvider != null && xmlParentProvider._parentSiteMapFileCollection != null) {
                if (xmlParentProvider._parentSiteMapFileCollection.Contains(_normalizedVirtualPath.VirtualPathString)) {
                    throw new InvalidOperationException(
                        SR.GetString(SR.XmlSiteMapProvider_FileName_already_in_use, _virtualPath));
                }

                // Copy the sitemapfiles in used from parent provider to current provider.
                foreach (string filename in xmlParentProvider._parentSiteMapFileCollection) {
                    _parentSiteMapFileCollection.Add(filename);
                }
            }

            // Add current sitemap file to the collection
            _parentSiteMapFileCollection.Add(_normalizedVirtualPath.VirtualPathString);

            _filename = HostingEnvironment.MapPathInternal(_normalizedVirtualPath);

            if (!String.IsNullOrEmpty(_filename)) {
                _handler = new FileChangeEventHandler(this.OnConfigFileChange);
                HttpRuntime.FileChangesMonitor.StartMonitoringFile(_filename, _handler);
                ResourceKey = (new FileInfo(_filename)).Name;
            }

            _document = new ConfigXmlDocument();

            return _document;
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:55,代码来源:XmlSiteMapProvider.cs

示例4: MapPath

 internal string MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, bool allowCrossAppMapping)
 {
     if (this._wr == null)
     {
         throw new HttpException(System.Web.SR.GetString("Cannot_map_path_without_context"));
     }
     if (virtualPath == null)
     {
         virtualPath = VirtualPath.Create(".");
     }
     VirtualPath path = virtualPath;
     if (baseVirtualDir != null)
     {
         virtualPath = baseVirtualDir.Combine(virtualPath);
     }
     if (!allowCrossAppMapping)
     {
         virtualPath.FailIfNotWithinAppRoot();
     }
     string str = virtualPath.MapPathInternal();
     if (((virtualPath.VirtualPathString == "/") && (path.VirtualPathString != "/")) && (!path.HasTrailingSlash && UrlPath.PathEndsWithExtraSlash(str)))
     {
         str = str.Substring(0, str.Length - 1);
     }
     InternalSecurityPermissions.PathDiscovery(str).Demand();
     return str;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:HttpRequest.cs

示例5: RewritePath

 internal void RewritePath(VirtualPath filePath, VirtualPath pathInfo, string queryString, bool setClientFilePath)
 {
     if (filePath == null)
     {
         throw new ArgumentNullException("filePath");
     }
     filePath = this.Request.FilePathObject.Combine(filePath);
     filePath.FailIfNotWithinAppRoot();
     this.ConfigurationPath = null;
     this.Request.InternalRewritePath(filePath, pathInfo, queryString, setClientFilePath);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:HttpContext.cs


注:本文中的System.Web.VirtualPath.FailIfNotWithinAppRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。