2017-05-21 2 views
0

이 코드는 localhost/IIS에서 완벽하게 작동합니다. 첨부 된 pdf로 이메일을받습니다. 그러나, 그것을 IIS7 서버에 복사하면 실패합니다. 어떤 아이디어?이 전자 메일 첨부 파일이 로컬 호스트가 아닌 asp.net 서버에서 실패하는 이유는 무엇입니까?

The device is not ready. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.IOException: The device is not ready. 


Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


IOException: The device is not ready. 

    System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +1093 
    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, Boolean useLongPath, Boolean checkHost) +886 
    System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +127 
    System.Net.Mail.AttachmentBase.SetContentFromFile(String fileName, String mediaType) +104 
+0

오류 메시지를 게시 할 수 있습니까? –

+0

죄송합니다. 그냥 잊어 버리 셨습니다. pdf 파일을로드하려고 할 때 "장치가 준비되지 않았습니다". –

+0

좋아요 ... 문제가 해결되었습니다. 로컬 개발 상자에서 모든 것을 다시 컴파일하고 서버에 다시 배포했습니다. 5 ~ 6 번 시도한 후에 지금 일하기 시작했습니다 ... 이유는 모르겠지만, 이봐 요, 그 일은 .... –

답변

0

오류 Device Not Ready는 일반적으로 주어진 위치가 존재하지 않음을 나타냅니다 :

var db = new DirectCellarsModel(); 
      var status = false; 
      MailAddress from = new MailAddress(EMAIL_SENDER); 
      MailAddress to = new MailAddress(recipient); 
      MailMessage message = new MailMessage(from, to); 
      message.Subject = subject; 
      message.Body = messageBody; 

      if (pdf) 
      { 
       Attachment data = new Attachment(@"C:\develop\PDF\myfree.pdf", MediaTypeNames.Application.Octet); 
       message.Attachments.Add(data); 
      } 

      SmtpClient client = new SmtpClient(SMTP_CLIENT); 

는 오류 메시지입니다. 일반적으로 드라이브 자체는 존재하지 않지만이 경우 서버에 C 드라이브가 없다는 것을 나타낼 수 없습니다 (그러나 서버가 다른 장치에서 부팅 될 수 있음). 드라이브와 드라이브의 폴더가 실제로 있는지 확인하십시오.

확인 디버깅에 대한 정보와 기타 가능한 문제에 대한뿐만 아니라이 답변 : 위치가 존재

'device not ready' while using File.Copy() in C#

경우, 사용자가 읽을 수있는 권한이 있는지 확인합니다. 익명 사용자는 IUser으로 식별됩니다.

+0

존재합니다. 나는 그것을 여러 번 검증했다. –

+0

파일 경로는 어떻게됩니까? 전체 경로를 하드 코딩하는 것은 결코 좋은 생각이 아닙니다. – krillgar

+0

내 대답에 추가했습니다 .... –

0

"C : \ develop \ PDF \"위치가 서버에있는 경우에도 IIS_USER 계정 (또는 다른 계정)이 해당 위치에 액세스 할 수있는 전체 권한이 없을 수 있습니다.

쉽게 액세스 할 수있는 IIS 계정에 대한 관련 권한으로 웹 사이트의 루트에서 하위 폴더를 설정하는 것이 좋습니다.

관련 문제