1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need yours help about javaScript in ASP (2)

Discussion in 'C#' started by john_vn, Oct 27, 2005.

  1. #1
    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
     
    john_vn, Oct 27, 2005 IP
  2. Arnica

    Arnica Peon

    Messages:
    320
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have you told the server to expect JScript?

    <%@ Language=JavaScript %>
     
    Arnica, Oct 28, 2005 IP
  3. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #3
    By 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.
     
    J.D., Oct 28, 2005 IP
  4. lbordea

    lbordea Peon

    Messages:
    74
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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...
     
    lbordea, Nov 1, 2005 IP
  5. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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.
     
    J.D., Nov 1, 2005 IP