在subdomain.domainname
中,我有一个通用处理程序,它应该从domainname
加载图像
Dim Path As String = "http://www.domainname/"
context.Response.ContentType = "image/jpg"
context.Response.WriteFile(Path & ImgName & ".jpg")
问题是我无法添加物理路径,因为Responce.WriteFile接受物理路径。我得到了有效的虚拟路径错误。
那么当domainname
中的图像存在且我的通用处理程序位于subdomain.domainname
时,如何加载图像?
有什么诀窍,我可以使用吗?
我不想将处理程序移动到domainname
答案 0 :(得分:2)
您可以先下载图像,然后将缓冲区写入响应:
Using client = New WebClient()
' This assumes that http://www.domainname.com/ returns a JPEG image
Dim file As Byte() = client.DownloadData("http://www.domainname.com/")
context.Response.ContentType = "image/jpg"
Dim filename = Path.ChangeExtension(imgFile, "jpg")
context.Response.AppendHeader("Content-Disposition", "inline; filename=" & filename);
context.Response.OutputStream.Write(file, 0, file.Length)
End Using
答案 1 :(得分:0)
为什么不将请求重定向到非子域?
context.Response.Redirect(Path & ImgName & ".jpg")
答案 2 :(得分:0)
我只是在这里抛出明显的东西,但你不是错过了顶级域名,即.com
吗?
http://www.mydomain.com/