本文整理汇总了C#中System.Web.HttpResponse.WriteVirtualFile方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponse.WriteVirtualFile方法的具体用法?C# HttpResponse.WriteVirtualFile怎么用?C# HttpResponse.WriteVirtualFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.WriteVirtualFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequestForNonMapPathBasedVirtualFile
private static bool ProcessRequestForNonMapPathBasedVirtualFile(HttpRequest request, HttpResponse response, string overrideVirtualPath) {
bool handled = false;
// only process custom virtual path providers here
if (HostingEnvironment.UsingMapPathBasedVirtualPathProvider) {
return handled;
}
VirtualFile virtualFile = null;
String virtualPath = (overrideVirtualPath == null) ? request.FilePath : overrideVirtualPath;
if (HostingEnvironment.VirtualPathProvider.FileExists(virtualPath)) {
virtualFile = HostingEnvironment.VirtualPathProvider.GetFile(virtualPath);
}
if (virtualFile == null) {
Debug.Trace("StaticFileHandler", "Virtual file " + virtualPath + " not found");
throw new HttpException( HttpStatus.NotFound,
SR.GetString(SR.File_does_not_exist) );
}
// if we have a MapPathBasedVirtualFile, we can handle it the normal way
if (virtualFile is MapPathBasedVirtualFile) {
return handled;
}
Debug.Trace("StaticFileHandler", "Using VirtualPathProvider for " + virtualPath);
response.WriteVirtualFile(virtualFile);
response.ContentType = MimeMapping.GetMimeMapping(virtualPath);
handled = true;
return handled;
}
示例2: ProcessRequestForNonMapPathBasedVirtualFile
private static bool ProcessRequestForNonMapPathBasedVirtualFile(HttpRequest request, HttpResponse response, string overrideVirtualPath)
{
bool flag = false;
if (HostingEnvironment.UsingMapPathBasedVirtualPathProvider)
{
return flag;
}
VirtualFile vf = null;
string virtualPath = (overrideVirtualPath == null) ? request.FilePath : overrideVirtualPath;
if (HostingEnvironment.VirtualPathProvider.FileExists(virtualPath))
{
vf = HostingEnvironment.VirtualPathProvider.GetFile(virtualPath);
}
if (vf == null)
{
throw new HttpException(0x194, System.Web.SR.GetString("File_does_not_exist"));
}
if (vf is MapPathBasedVirtualFile)
{
return flag;
}
response.WriteVirtualFile(vf);
response.ContentType = MimeMapping.GetMimeMapping(virtualPath);
return true;
}