programing

ASP.net Getting the error "Access to the path is denied." while trying to upload files to my Windows Server 2008 R2 Web server

oldcodes 2023. 9. 11. 22:13
반응형

ASP.net Getting the error "Access to the path is denied." while trying to upload files to my Windows Server 2008 R2 Web server

I have an asp.net webapplication that uploads files to a specific folder on the Web server. locally everything works fine, but when I deploy the application to the Webserver, I begin getting the error "Access to the path "D:\Attachments\myfile.doc" is denied". I gave the "IIS AppPool" user that the application is running under full permission on the folder. I even gave "Everyone" full permissions, but with the same error.

I added the folder to the Exceptions list of the Antivirus, but with the same result. I am begining to suspect that maybe Windows Server 2008 R2 needs a trick for my upload to work. I really appreciate your help.

Thanks

Right click on your folder on your server or local machine and give full permissions to

IIS_IUSRS

that's it.

asp.net 계정{MACHINE}\ASPNET해당 위치에 대한 쓰기 권한이 없습니다.그것이 그것이 실패한 이유입니다.

Consider granting access rights to the resource to the ASP.NET request identity.

폴더 다운로드 우클릭Properties > Security Tab > Edit > Add > locations > choose your local machine > click OK > Type ASPNET below "Enter the object name to select" > Click Check Names원하는 액세스를 위해 상자를 확인합니다(Full Control만약 그것이 당신에게 효과가 없다면, 당신은 같은 방법을 사용합니다.Network Service

이제 이것은 당신의 지역을 보여줄 것입니다.{MACHINENAME}\ASPNETaccount, 그런 다음 이 계정에 쓰기 권한을 설정합니다.

그렇지 않으면 응용프로그램이 다음을 통해 사칭하는 경우<identity impersonate="true"/>, 신원은 익명의 사용자(일반적으로)가 됩니다.IUSR_MACHINENAME또는 인증된 요청 사용자를 입력합니다.


또는 파일을 ASP에 저장하는 전용 위치를 사용하기만 하면 됩니다.NET는App_Data. 작성하려면 ASP를 마우스 오른쪽 버튼으로 클릭합니다.NET 프로젝트(Visual Studio에서)Add > Add ASP.NET Folder > App_Data. 그러면 이 위치에 데이터를 저장할 수 있습니다.

var path = Server.MapPath("~/App_Data/file.txt");
System.IO.File.WriteAllText(path, "Hello World");

the problem might be that networkservice has no read rights

salution:

rightclick your upload folder -> poperty's -> security ->Edit -> add -> type :NETWORK SERVICE -> check box full control allow-> press ok or apply

If anyone stumbles across this as it is the first result in google,

remember to specify the filename too in the SaveAs method.

Won't work

file_upload.PostedFile.SaveAs(Server.MapPath(SaveLocation));

You need this:

filename = Path.GetFileName(file_upload.PostedFile.FileName);
file_upload.PostedFile.SaveAs(Server.MapPath(SaveLocation + "\\" + filename));

I assumed the SaveAs method will automatically use the filename uploaded. Kept getting "Access denied" error. Not very descriptive of the actual problem

저는 이 문제에 한 번 직면했는데, 제 경우에는 해당 파일을 사용/액세스하는 작업 관리자의 모든 프로세스를 닫는 것이 해결책입니다.

[고급 보안 설정] 아래를 살펴보셨습니까?

이미지 아래와 같은 것 IIS_IUSRS로 폴더 변경 권한

enter image description here

게임이 늦었다는 것을 알지만, 누군가에게 도움이 될 경우를 대비해 공유하고 싶었습니다.

당신의 정확한 상황이 적용되지 않을 수도 있지만, 저도 비슷한 상황이었고, 파일 속성을 설정하는 것이 도움이 되었습니다.

File 특성을 Normal로 설정해 봅니다.

var path = Server.MapPath("~/App_Data/file.txt");
File.SetAttributes(path, FileAttributes.Normal);
System.IO.File.WriteAllText(path, "Hello World");

누군가에게 도움이 되었으면 좋겠습니다.

무엇을 쓰려고 하는지 확인합니다.같은 문제가 있었지만 길이가 0인 바이트 배열을 작성하려고 했습니다.

이해가 안 되지만, "경로 접근"이란 말을 듣습니다.

루트 폴더로 이동

마우스 오른쪽 버튼을 클릭하고 속성을 클릭합니다.

탭 보안 선택

편집 클릭

추가 클릭

'Every One'을 입력

확인을 누릅니다.

체크아웃 풀 컨트롤

확인을 누릅니다.

언급URL : https://stackoverflow.com/questions/19724297/asp-net-getting-the-error-access-to-the-path-is-denied-while-trying-to-upload

반응형