2010-04-27 1 views
1

메서드에 대한 매개 변수로 전달되는 경로에 텍스트 파일을 만들 ASP.NET 웹 서비스가 있습니다.웹 서비스가 가상 디렉터리로 배포 된 경우 사용 권한 문제가 발생합니다. VS IDE의 작업

private void CreateFile(string path) 
{ 
     string strFileName = path; 
     StreamWriter sw = new StreamWriter(strFileName, true); 
     sw.WriteLine(""); 
     sw.Write("Created at " + DateTime.Now.ToString()); 
     sw.Close(); 
} 

가 지금은 매개 변수로 네트워크에서 폴더를 전달하고 방법

CreateFile(@"\\192.168.0.40\\labels\\test.txt"); 

비주얼 스튜디오 IDE에서 코드를 실행 호출하고, 파일이 path.But에 만들어지고 내가이 출판 가상 directoty로 배포 할 때, 그것의 내가 내 web.config.My 기계에있는

"System.UnauthorizedAccessException: Access to the path '\\192.168.0.40\labels\test.txt' is denied. 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) 
    at System.IO.StreamWriter.CreateFile(String path, Boolean append) 
    at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize) 
    at System.IO.StreamWriter..ctor(String path, Boolean append) 

처럼 나에게 몇 가지 오류를 던지고는 XP에서 실행되고 다른 하나는 Windows Server 2003에서입니다 . 해당 폴더에 대해 "모든 사용자"에게 쓰기 권한을 설정했습니다.

이 문제를 해결하려면 어떤 아이디어가 필요합니까 ?? 미리 감사드립니다.

답변

1

웹 응용 프로그램은 네트워크의 리소스에 액세스 할 수없는 로컬 aspnet 사용자 계정으로 실행됩니다. IIS 버전에 응용 프로그램 풀이있는 경우 응용 프로그램 풀 사용자에게 네트워크 리소스에 대한 액세스 권한이있는 도메인 사용자로 만들어야합니다. 응용 프로그램 풀이없는 경우 web.config의 processModel 요소에서 웹 사용자를 변경합니다.