2013-05-16 3 views
0

일부 메뉴 항목이있는 마스터 페이지를 정의합니다. 파일 업로드 컨트롤을 사용하여 파일의 내용을 표시하여 다른 콘텐츠 페이지 : newModel.aspx 페이지에서 열면 문제가 발생합니다. 그것의 일할 것이다 그러나 나는 오류를 얻는 메신저를 표시한다 : "C : \ Program Files (x86) \ Common Files \ Microsoft Shared \ DevServer \ 10.0 \ C % 3a % 5cUsers % 5chhassan % 5cDocuments % 5cVisual + Studio + 2010 % 5cWebSites % 5cKBD-2013 % 5cModel % 5cTest.edd '.'C : Program Files (x86) Common Files Microsoft Shared DevServer 10.0'파일을 찾을 수 없습니다.

C# MasterPage 코드 :

protected void Open_btn_click(object sender, EventArgs e) 
{ 
    bool fileOK = false; 
    string SampleDocuments = Server.MapPath(string.Empty); 
    if (FileUploadCtrl.HasFile) 
    { 
     string fileExtension = System.IO.Path.GetExtension(FileUploadCtrl.FileName).ToLower(); 
     string allowedExtension = ".edd"; 
     if (fileExtension == allowedExtension) 
     { 
      fileOK = true; 
     } 
    } 
    if (fileOK == true) 
    { 

     string fileName = SampleDocuments + "\\Model" + "\\" + FileUploadCtrl.FileName; 
     Response.Redirect("~/Model/newModel.aspx?fileName=" + fileName); 
    } 

newmodel에 페이지 번호 :

protected void Page_Load(object sender, EventArgs e) 
{ 
    String fileName = HttpUtility.UrlEncode(Request.QueryString["fileName"]); 
    this.DiagramWebControl1.LoadBinaryDocument(fileName); 
} 

답변

1

응용 프로그램이 (IIS가, 개발 서버를 IIS), 당신이 Server.MapPath("~")와 함께 일해야 호스팅 모드에서 실행하는 경우 실제 디렉토리를 얻으십시오. 기본적으로 현재 작업 디렉토리는 웹 서버의 작업 디렉토리를 가리 킵니다. 자세한 내용은 http://msdn.microsoft.com/de-de/library/system.web.httpserverutility.mappath.aspx

+0

내 응용 프로그램은 로컬 호스트에서 실행 중 –

+0

IIS를 사용하고 있습니까? 아니면 IIS 개발 서버? –

+0

죄송합니다. IIS를 사용하여 이것을 쓰는 것을 잊지 마십시오. –