簡體   English   中英

在ASP中創建文本文件時拒絕權限

[英]Permission denied when creating text file in asp

我有以下代碼:

<%
dim deviceid
dim fso
dim outFile

deviceid=Request.QueryString("deviceid")

If deviceid<>"" Then
    Response.Write("Hello " & deviceid & "!<br>")

    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    Set outFile = fso.CreateTextFile("C:\Users\Victor\Desktop\respTank.txt")
    outFile.WriteLine("Hello World!")
    outFile.close

    set outFile = nothing
    set fso = nothing

End If
%>

我收到以下錯誤:

Microsoft VBScript runtime error '800a0046'
Permission denied

我為IIS_IUSRS授予了所有權限,但沒有幫助。 有人能幫我一下嗎?

聽起來ApplicationPoolIdentity不是Web應用程序正在使用的用戶上下文。

您要檢查(取決於IIS版本)(使用管理器)

IIS 4-6

網站/應用程序屬性-> Document Security

IIS 7+

網站/應用程序-> Authentication

並檢查可以與ApplicationPoolIdentity設置不同的Anonymous Account

基於此值,將權限(至少是Modify )應用於文件夾C:\\Users\\Victor\\Desktop\\ ,您可以開始使用。

我剛在刪除文件上發生了同樣的事情,您是否嘗試過刪除括號?

Set outFile = fso.CreateTextFile("C:\Users\Victor\Desktop\respTank.txt")

Set outFile = fso.CreateTextFile "C:\Users\Victor\Desktop\respTank.txt"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM