本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}