Authentication required

Last post 01-11-2010, 7:49 PM by cutechat. 4 replies.
Sort Posts: Previous Next
  •  01-10-2010, 6:12 PM 58109

    Authentication required

    Hello,
     
    I am able to upload the file successfully however when I try to display it - it is keep asking me authentication required window. I have given full permission to the folder where the file is going.. so not sure how to solve it.
     
    Any help would be great.
    SK
  •  01-10-2010, 8:41 PM 58112 in reply to 58109

    Re: Authentication required

    SK,
     
    Do you mean you upload the file and store to http://yourhost.com/files/aaa.xxx , and when access it using http, it show requires permission ?
     
    Regards,
    Terry
     
  •  01-11-2010, 8:21 AM 58117 in reply to 58112

    Re: Authentication required

    That is correct Terry..
  •  01-11-2010, 4:21 PM 58121 in reply to 58112

    Re: Authentication required

    Any ideas Terry ..
  •  01-11-2010, 7:49 PM 58125 in reply to 58117

    Re: Authentication required

    Hi,
     
    How do you copy the temporary file to the folder ?
     
    I think the reason is that the temp file have special permission setting in windows temp folder.
     
    And when you copy it to website folder, the permission is also copied.
     
    Maybe you can try this way :
     

     void Uploader_FileUploaded(object sender, UploaderEventArgs args)
     {
      string newfilepath = Path.Combine(Server.MapPath("~/myfolder"), args.FileName);
      using (FileStream newfile = new FileStream(newfilepath, FileMode.Create, FileAccess.Write, FileShare.None))
      {
       using (Stream srcfile = args.OpenStream())
       {
        byte[] buff = new byte[65536];
        int rc;
        while (true)
        {
         rc = srcfile.Read(buff, 0, buff.Length);
         if (rc <= 0)
          break;
         newfile.Write(buff, 0, rc);
        }
       }
      }
     }

     
    Regards,
    Terry
View as RSS news feed in XML