By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,481 Members | 1,713 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,481 IT Pros & Developers. It's quick & easy.

window.open issue

P: n/a
Hi All,

I am attempting to do something I thought would be simple. From one
of my asp.net pages, I need for the user to be able top open up
documents(any file format - .xls, .doc, .pdf, etc). To accomplish
this, I am using javascript:

<code>
<script type="text/javascript">
function open_win()
{
window.open('file://C:/DEV/Procurement2008/ProcurementSystem/Images/
dbStylemaster.ppt')
}
</script>
</code>

I am getting "Access is Denied".

This file I am trying to open is on my hard drive and I am running the
asp.net program locally as I am developing. Eventually, the files
will be stored on a web server.

I have done a lot of searching this morning and am just more
confused. Am I attempting to do something that won't be allowed
because of security?

Thansk in advance for your help!

JCC
Aug 4 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
JCCDevel wrote:
I am attempting to do something I thought would be simple. From one
of my asp.net pages, I need for the user to be able top open up
documents(any file format - .xls, .doc, .pdf, etc). To accomplish
this, I am using javascript:

<code>
This is Usenet. Please do not bother (us) with pseudo-tags.
<script type="text/javascript">
function open_win()
{
window.open('file://C:/DEV/Procurement2008/ProcurementSystem/Images/
dbStylemaster.ppt')
For a proper file:// URI, you need to add another slash before the C: to
specify the local host. (The `localhost' host name after it is optional then.)

But this method only constitutes overhead.
}
</script>
</code>

I am getting "Access is Denied".
^^^^^^^^^^^^^^^^
This file I am trying to open is on my hard drive and I am running the
asp.net program locally as I am developing. Eventually, the files
will be stored on a web server.

I have done a lot of searching this morning and am just more
confused. Am I attempting to do something that won't be allowed
because of security?
That much would be obvious, would it not?

You are attempting to access a file:// resource from a http(s):// resource.
The client application does not care, because it cannot know, that both are
on the same machine. So access is denied.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Aug 4 '08 #2

P: n/a
Thomas 'PointedEars' Lahn a écrit :
JCCDevel wrote:
>I am attempting to do something I thought would be simple. From one
of my asp.net pages, I need for the user to be able top open up
documents(any file format - .xls, .doc, .pdf, etc). To accomplish
this, I am using javascript:

<code>

This is Usenet. Please do not bother (us) with pseudo-tags.
This is Usenet. Don't talk in the name of the whole group, don't say
*us* there is no "us".

Talk in your OWN name, thanks.

--
laurent
Aug 4 '08 #3

P: n/a
On Aug 4, 1:43 pm, JCCDevel <JCCMo...@gmail.comwrote:
window.open('file://C:/DEV/Procurement2008/ProcurementSystem/Images/
You could write a tiny http "server" for the localhost, e.g. listening
on ip 127.0.0.1:80 then use URL of the form http://c/path where this
tiny server converts /c/path into c:\path to open and read whole file
into a buffer, then send it to the socket. I have done something like
that (also for code development) by rigging our existent http server
source (the iPhone remote desktop & file server, http://f2p.com ) with
that kind of custom file i/o. You can probably find some tiny http
server source on the web and spend few hours on customization. That
scheme also lets you dump js debug strings (e.g. via XMLHttpRequest)
to the console on the server side, without disrupting display on the
client side.
Aug 4 '08 #4

P: n/a
wayne wrote:
On Aug 4, 1:43 pm, JCCDevel <JCCMo...@gmail.comwrote:
>window.open('file://C:/DEV/Procurement2008/ProcurementSystem/Images/

You could write a tiny http "server" for the localhost, e.g. listening on
ip 127.0.0.1:80 then use URL of the form http://c/path where this tiny
server converts /c/path into c:\path to open and read whole file into a
buffer, then send it to the socket.
ISTM this server would listen, but would not hear anything. In this URI,
`c' would be the host name, and that is what would have to be defined in the
local `hosts' file as an alias for `localhost', as an alternative DNS record
would be either invalid or complicate maintenance.
I have done something like that (also for code development) by rigging
our existent http server source (the iPhone remote desktop & file server,
http://f2p.com ) with that kind of custom file i/o.
That was probably http://localhost/c/...
You can probably find some tiny http server source on the web and spend
few hours on customization.
I would probably use a very basic TCP sockets based service instead; I
hacked one together using a Java tutorial[1] in about one hour, about 120
LOC (pretty-printed). I had written almost no Java code before; if you can
write J(ava)Script, you can also write this one. (Eclipse, of course, came
in very handy :))

However, the OP already has a local server with ASP .NET; I recommend to use
the existing infrastructure instead.
PointedEars
___________
[1] Abts, Dietmar: Masterkurs Client/Server-Programmierung mit Java;
pp. 106; 2. Auflage; April 2007; Vieweg & Sohn.
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Aug 4 '08 #5

P: n/a
That was probably http://localhost/c/...

Yep, I dopped accidentally the host above.
Aug 4 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.