开发者

ASP.net: Cannot write to App_Data folder, Access is Denied

Typical problem, but I've done everything I can possibly think of to get this to work. I set the NETWORK SERVICE and ASPNET accounts to FULL CONTROL on my PC. I'm using the built-in Cassi开发者_JAVA百科ni web server to test my application, with no luck. I even tried to make a folder outside of the APP_DATA folder, and is still says Access is Denied.

Anyone have any ideas?

CODE EXAMPLE:

  Dim uploadedFile As HttpPostedFile = Request.Files(0)
        Dim len As Integer = uploadedFile.ContentLength
        Dim fn As String = Path.GetFileName(uploadedFile.FileName)
        Dim SaveLocation As String = Server.MapPath("~/Help")
        Dim MyStream As Stream = uploadedFile.InputStream
        Dim input(len) As Byte

        MyStream = uploadedFile.InputStream
        MyStream.Read(input, 0, len)

        Try

            Dim newFile As FileStream = New FileStream(SaveLocation, FileMode.Create)
            newFile.Write(input, 0, input.Length)
            newFile.Close()
            'Dim writer As Stream = New FileStream(SaveLocation, FileMode.Create)
            'writer.Read()
            'writer.Close()
            'uploadedFile.SaveAs(SaveLocation)
        Catch ex As Exception

        End Try


Alright, I figured it out. I needed to have the filename in the SaveLocation. Completely missed that. Thanks for your help.


Which version of IIS are you using?

On IIS 6 and higher it is NETWORK SERVICE.

On IIS 5 and below it is the ASPNET user account that needs the required access.


If you're using IIS, find out what system (or user) account for the application pool for the site you are having issues with. Check to make sure that that user has permissions to the folder in question.

If you're in Visual Studio 2005+, it is rolling up a new ASP.NET Development Server. This runs as your currently logged-in account. Are you a local admin on this machine?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜