Open document from server on client
-
Hi, I have a list of doc files located on a server, I need to open them on a client side in asp .net form. I don't want the users to be able to enter the directories or the files (security permissions) directly, \\servername\c$\directory name, so I removed all security permissions, but I still want the users to be able to open the files from the web site, can you help me? thanks, Yefi
modified on Tuesday, February 15, 2011 7:59 AM
-
Hi, I have a list of doc files located on a server, I need to open them on a client side in asp .net form. I don't want the users to be able to enter the directories or the files (security permissions) directly, \\servername\c$\directory name, so I removed all security permissions, but I still want the users to be able to open the files from the web site, can you help me? thanks, Yefi
modified on Tuesday, February 15, 2011 7:59 AM
You can receive the filename by a querystring.
string filename = Request.QueryString["filename"];
Then you can validate everything you need and, if the file is a simple textfile, you can open it and write all its contents to the page. You can even do this with other file formats, but then you must set the document type and maybe need to use a page only to "download" the file.
-
You can receive the filename by a querystring.
string filename = Request.QueryString["filename"];
Then you can validate everything you need and, if the file is a simple textfile, you can open it and write all its contents to the page. You can even do this with other file formats, but then you must set the document type and maybe need to use a page only to "download" the file.
-
Not good for me, if the filename permissions on the server are minimum I can't open the file.
But not even the code running at the server side is able to open the file? If that's the case, it will be impossible to solve. I think what you want is something like this: Direct connections to a folder or http folder: They are not able to access the files. Connections to a page - Such page will be able to see only files located at "some directory". If "some directory" is protected from reading, you may need some type of impersonation. But, then, the flow will be: Clients (without any access) will access your page at the server. Such page will have some type of impersonation, can verify if the file only contains the names (no .., no drive letter and so on) and, even then, it only has access to one directory. It reads the file (if valid) and then returns its contents. If you need, I can detail better about impersonation, but I don't think that you will really need that.
-
Hi, I have a list of doc files located on a server, I need to open them on a client side in asp .net form. I don't want the users to be able to enter the directories or the files (security permissions) directly, \\servername\c$\directory name, so I removed all security permissions, but I still want the users to be able to open the files from the web site, can you help me? thanks, Yefi
modified on Tuesday, February 15, 2011 7:59 AM
First you need to give the user some way of selecting which file they need to open. This can be done through may ways, may be you list all the files on you page? Once a user selects (knows) which file they want, they don't permission on the server side. But asp.net will definitely need a permission to read/access the files from that folder. If asp.net does not have permission then it will fail.
Yusuf May I help you?
-
Hi, I have a list of doc files located on a server, I need to open them on a client side in asp .net form. I don't want the users to be able to enter the directories or the files (security permissions) directly, \\servername\c$\directory name, so I removed all security permissions, but I still want the users to be able to open the files from the web site, can you help me? thanks, Yefi
modified on Tuesday, February 15, 2011 7:59 AM
In order to open the document on the client side, the encoding must be set to an appropriate type for the relevant document. The thing you need to set is known as the MIME type, for instance - if you want to open up an Excel document, the content type should be set to application/vnd.ms-excel. I hope that this helps.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads