Mam zamiar przesłać plik załączony z kontrolki FileUpload na zewnętrzny serwer FTP
Aplikacja działa bez problemu jednak tylko lokalnie, po wrzuceniu na serwer wyrzuca błąd.
Próbowałem wszystkiego. Poniżej kod oraz komunikat błędu. Aplikacja na serwerze somee.com
protected void Button6_Click(object sender, EventArgs e)
{
System.Net.WebClient webClient = new System.Net.WebClient();
string webAddress = @"ftp://mojftpzewnetrzny.opx.pl/plik/";
webClient.Credentials = new System.Net.NetworkCredential("[email protected]", "mojehaslo");
string name = Path.GetFileName(FileUpload1.FileName);
byte[] data = FileUpload1.FileBytes;
webClient.UploadData(webAddress + name, data);
webClient.Dispose();
string sciezka = "http://mojftpzewnetrzny.opx.pl/plik/" + FileUpload1.PostedFile.FileName;
Label3.Text = sciezka;
}
komunikat błędu:
Server Error in '/' Application.
The underlying connection was closed: The server committed a protocol violation.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:
[WebException: The underlying connection was closed: The server committed a protocol violation.]
System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) +303
System.Net.WebClient.UploadData(Uri address, String method, Byte[] data) +152
System.Net.WebClient.UploadData(String address, Byte[] data) +34
zapis1.pliki.Button6_Click(Object sender, EventArgs e) in c:\Users\mcha\Documents\Visual Studio 2012\Projects\zapis1.1\zapis1\pliki.aspx.cs:93
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628614
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
Czy ktoś ma jakiś pomysł ?