Jump to content
Xtreme .Net Talk

Upload File Exception (Logon failure: unknown user name or bad


Recommended Posts

Posted

Hi,

 

I'm trying to upload a file in my ASP.NET application (C#). In my

webform I have an input file control with runat=server. In my code written in the code behind file,I specify my destination directory as a network path and I'm using the function HttpPostedFile.SaveAs (string filename) to save the uploaded file. My code runs fine when my destination directory is on some machines, and produces an exception when my desrtination directory is on other machines although i made sure that all the directories I'm trying to upload my files on have read,change & full control permissions for EVERYONE.

 

The exception I'm getting is:

 

System.IO.IOException: Logon failure: unknown user name and/or bad password.

 

This is the function I'm using for Upoading files in the code behind file:

 

private void UploadFile(string sFileDir, long lMaxFileSize)

{

 

if (( Request.Files[0] != null) && (

 

Request.Files[0].ContentLength > 0))

{

//determine file name

string sFileName =

 

System.IO.Path.GetFileName(Request.Files[0].FileName);

try

{

if

 

(Request.Files[0].ContentLength <= lMaxFileSize)

{

//Save File on

 

disk

 

 

Request.Files[0].SaveAs(sFileDir + sFileName);

 

 

lblMessage.Visible=true;

 

 

lblMessage.Text="File: " + sFileDir + sFileName + " Uploaded

 

Successfully";

}

else //reject file

{

 

 

lblMessage.Visible=true;

 

 

lblMessage.Text="File Size if Over the Limit of " + lMaxFileSize ;

}

}

catch(Exception ex)//in case of

 

an error

{

lblMessage.Visible =

 

true;

lblMessage.Text="An

 

Error Occured. Please Try Again!";

 

 

lblMessage.Text+="ex.Message=" + ex.Message +

 

",ex.toString()="+ex.ToString();

 

}

}

}

 

Does anyone have a clue wha may be the cause of this exception

happening on some machines and not on others ? Do I have to set any other permissions except those set to EVERYONE on the destination directory ?

 

Thanks

Posted
But the account I'm using for the anonymous access of the virtual directory of my web application is a domain administration account not IUSer<machinename>, and this user has previliges on any machine in the domain.
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...