Xbox Mod Chip - Remortgages - Mobile Phones - Mortgage Calculator - Flights

PDA

View Full Version : Need yours help about javaScript in ASP (2)


john_vn
Oct 27th 2005, 8:02 pm
this JavaScript code cannot run, and get a deny permisson .
<body>
<%
TFile = Server.CreateObject("Scripting.FileSystemObject");
TFileStream = TFile.CreateTextFile("C:\inetpub\wwwroot\ABG\ASP\Test.txt",true);
TFileStream.WriteLine("Hello World");
TFileStream.Close();
%>
</body>

While this VBScript code runned well :

</body>
<%
set TestFile = Server.CreateObject("Scripting.FileSystemObject")
set TFileStream = TFile.CreateTextFile("C:\inetpub\wwwroot\ABG\ASP\Test.txt",true)
TFileStream.WriteLine "Hello World"
TFileStream.Close
%>
</body>

What shoul i do now so that this JavaScript code can run as same as VBScript

Arnica
Oct 28th 2005, 2:34 am
Have you told the server to expect JScript?

<%@ Language=JavaScript %>

J.D.
Oct 28th 2005, 12:30 pm
this JavaScript code cannot run, and get a deny permissonBy default IIS executes ASP pages in the security context of a user called IUSR_machine_name. For security reasons this user has read-only access to the web root. This is why your attempt to write to a file located under web root fails. You can change permissions to allow IUSR to write in this directory, but then you will open your machine to all sorts of nasty stuff. Imagine, somebody manages to execute this script and create their own ASP page; then they will be able to read and even delete files on your machine.

J.D.

lbordea
Nov 1st 2005, 1:38 am
J.D., john_vn said that in VBcode it's working but it is not working in JScript code. That's the problem, right?
Maybe it is what Arnica said...

J.D.
Nov 1st 2005, 7:45 am
J.D., john_vn said that in VBcode it's working but it is not working in JScript code. That's the problem, right?
Maybe it is what Arnica said...You wouldn't get a permission-denied message from running the wrong type of script. Usually the VBscript engine would just report the first JScript line with a semicolon as an error.

May be his VBScript code isn't working after all - in the example he creates TestFile, but then actually uses TFile.

J.D.