尝试在浏览器中打开文件时,显示访问被拒绝错误 [英] When trying to open a file in my browser, it shows access is denied error
本文介绍了尝试在浏览器中打开文件时,显示访问被拒绝错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在浏览器中打开一个文件,它显示访问被拒绝错误
我试过System.Diagnostics.Process.Start(strFilePath& strFileName) ,这适用于本地但不在服务器上并尝试以下代码
I tried to open a file in my browser, it shows access is denied error
I tried System.Diagnostics.Process.Start(strFilePath & strFileName) , this works on local but not on server and tried the following code
strTemp = "<script language='javascript'>function NewWindow()
{window.open("file://C:\\Users\\Ruban Jayakumar\\Desktop\\New folder\\boot strap icons.txt",'testpage','directories=no,location=no,status=no,toolbar=no,menubar=yes,height=450,width=700,left=10,top=10,Resizable=yes');return false; }</script>"
ClientScript.RegisterClientScriptBlock(Me.GetType, "SecurityPolicy", strTemp)
但是发生了错误,还有其他选择吗?
but error occurs, is there any other option ??
推荐答案
这对你来说实际上是个好消息!!! br />
你在这里看到的是安全保障......
想象一下,任何一个人都可以写一个可以无限制地访问你的C:驱动器的网站......
因此,根据定义,网页无法访问浏览器运行的计算机上的本地驱动器...
...
但我怀疑你打算从你服务网页的服务器的C:驱动器中打开一个文件...如果一个人可以从一个网络服务器上访问驱动器,这应该是一个真正的安全灾难。网页只是因为它最初是从该服务器提供的...
如果你想从你的服务器共享一个文件,你有几个安全选项:
1.创建一个道琼斯为你做的nload按钮
2.使用虚拟目录共享文件
3.创建一个页面直接将文件流式传输到客户端...(使用简单网页流式传输文档 [ ^ ])
And it is actually good news for you!!!
What you saw here is security in action...
Imagine that anyone, who whish so can write a web site that can access your C: drive without any restriction...
So, by definition web pages have no access to the local drives on the computer on which the browser runs...
...
But I suspect that you meant to open a file from the C: drive of the server from where you served the web page...and it should be a real security disaster if a could access the drives on the web server from within a web page just because it was served from that server originally...
If you want to share a file from your server you have several secure options:
1. Create a download button that does it for you
2. Share the file using Virtual Directory
3. Create a page to stream the files directly to client...(Stream Your Documents Using Simple Web Page[^])
这篇关于尝试在浏览器中打开文件时,显示访问被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文