Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello Everybody! Look what my problem is ,i am writing a web application using ASP.NET in c#.In that i am trying to upload a file from my system to another system so for that i am using this code

 

void btnUploadTheFile_Click(object Source, EventArgs evArgs)

{

string strFileNameOnServer = txtServername.Value;

string strBaseLocation = ConfigurationSettings.AppSettings["filePath"];

;

 

if ("" == strFileNameOnServer)

{

txtOutput.InnerHtml = "give file name";

return;

}

 

if (null != uplTheFile.PostedFile)

{

try

{

uplTheFile.PostedFile.SaveAs(strBaseLocation+strFileNameOnServer);

txtOutput.InnerHtml = "File <b>" +

strBaseLocation+strFileNameOnServer+"</b> uploaded successfully";

}

catch (Exception e)

{

txtOutput.InnerHtml = "Error saving <b>" +

strBaseLocation+strFileNameOnServer+"</b><br>"+ e.ToString();

}

}

}

 

Now what is happening at one system it is uploading the file without any logon requirement but on many other systems it is giving this error.

 

System.IO.IOException: Logon failure: unknown user name or bad password. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at ASP.uploadNsave_aspx.btnUploadTheFile_Click(Object Source, EventArgs evArgs) in c:\inetpub\wwwroot\WebApplication3\uploadNsave.aspx:line 24

 

Now my requirement is that before saving on any system it must ask for anyuser name and password or user name and passqord must be sent from the client system to that particular system and after checking the validity based on that user name and password it must save the file.Now i am unable to find out how this will be done .So please help me out in removing this problem.

 

:confused:

Posted

Do you have this line in your Web.Config file?

 

<identity impersonate="true" />

 

This is needed to have the application authenticate using the Network/NT login

Posted

try everything

 

Hi!

I have done what you have said but now it is giving following error.

 

Error saving \\163.122.29.89\aaa\asd

System.UnauthorizedAccessException: Access to the path "\\163.122.29.89\aaa\asd" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at ASP.uploadNsave_aspx.btnUploadTheFile_Click(Object Source, EventArgs evArgs) in c:\inetpub\wwwroot\WebApplication3\uploadNsave.aspx:line 34 :(

Posted

explain it

 

Hi Robby.

 

Since i am a new in this field so i don't know what do you mean by third party libraries.Can you please explain what does this mean.

 

thanks.

punnu:)

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...