I wanted to know how I would be able to upload files to my server from my WinForms .exe application. I tried: My.Computer.Network.UploadFile(myFile, myServer) but I get this error 'The remote server returned an error: (404) Not Found.' Anyone know another way of uploading files to my server from a .exe? Thanks.
I'm using VB and .Net Framework 4
Here is another way, but it sounds like you are uploading to the wrong page (HTTP error = 404). Check your URL.
Dim fileName As String = AskUserForFileName()
Dim web As New WebClient()
web.UploadFile(uriString, fileName)
Related
I got this message in server log:
PhantomJs server unable to complete HTTP requests, preventing C1 Function preview images from being generated.
Composite.Core.WebClient.BrowserRenderException: ERROR, page.onResourceTimeout: "Network timeout on resource.", URL: "http://tempvala/Composite/blank.aspx"
Request: .CMSAUTH_-1796214875_757602046,41A53DFC3B8F0A3FCEC9860340804062FDA6CECBD2DF57EDF765A3E495C56F518A1F9195D76BC80B9F58B8CC7884B44B06DF96CEAAFC30717BDF00A0D80C7D955C4B3A4A2880C8018726C093824B5B0599D841C96ECA0B93501535F7B364BDA7,tempvala|http://tempvala/Composite/blank.aspx|C:\Sites\PublicUpgrade42\App_Data\Composite\Cache\Temp\phantomtest.png|test
at Composite.Core.WebClient.BrowserRender.PhantomServer.RenderUrl(HttpCookie authenticationCookie, String url, String tempFilePath, String mode, String& output)
at Composite.Core.WebClient.BrowserRender.CheckServerAvailability(HttpContext context, HttpCookie authenticationCookie)
I dont know what to do about this, and cant find any answers on internet.
Any help will be much appreciated.
Are you testing the website from the same machine where the website is hosted?
If not, it is required to map the host name 'tempvala' to 127.0.0.1 on the machine where the website is hosted as well. Function preview is generated by PhantomJs that is making HTTP requests, it is possible that it is failing to resolve the host name.
I have a strange case where a client's FTP server is fully browsable in a web browser, but not in a file explorer.
This is what I see in IE:
And this is what I see in Windows Explorer:
What I'm really trying is to write code that reads the list of files from this ftp directory:
Dim ftpRequest As FtpWebRequest = CType(WebRequest.Create(ftpServer), FtpWebRequest)
ftpRequest.Credentials = New NetworkCredential(ftpServerUsername, ftpServerPassword)
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails
Dim ftpResponse As FtpWebResponse = CType(ftpRequest.GetResponse(), FtpWebResponse)
Dim ftpResponseStream As Stream = ftpResponse.GetResponseStream()
Dim ftpResponseStreamReader As StreamReader = New StreamReader(ftpResponseStream)
Console.WriteLine(ftpResponseStreamReader.ReadToEnd())
ftpResponseStreamReader.Close()
ftpResponseStream.Close()
ftpResponse.Close()
But the code fails with a 451 error:
The remote server returned an error: (451) Local error in processing.
(Details: 451 requested action aborted: local error in processing)
Questions:
Why is the FTP browsable on IE but now in Windows? Should I tell my
client to change some properties on the FTP setup to make it
directory-browsable in Windows?
Is (1) necessary? Instead is it
possible to add/change my code to imitate web-browsing so that the
list of files can be read?
CiarĂ¡n's comment helped access files via Windows Explorer: the URL of the format ftp://username:password#IPAddress/ worked.
For the code, however, a slash "/" at the end of the URL did the trick!
I changed the directory name from ftp://server/directory to ftp://server/directory/ and BOOM! VB was able to retrieve the list of files!
I tried the same in IE, and here's what I get:
ftp://193.XX.XX.XX/flog:
ftp://193.XX.XX.XX/flog/: (note the "/" at the end of directory name)
Anyone else stumbling here with a (451) Local error in processing can try this and see if it helps!
Additional Note:
The URL of the format ftp://username:password#IPAddress/ (again, note the ending "/") also works in code. With this, you can skip the line ftpRequest.Credentials = ....
I am writing an application that gets its data from many small servers (the "servers" are data loggers and the app consumes the data from the loggers). The data exists as files on the server and I have been using SSH FTP to get the files. Specifically I'm using the .NET wrapper for WinSCP
I have had some problems with this, some transfer fail (while Filezilla succeeds) and it does not report progress. Also, the downloads can be long due to limited bandwidth at the server. So I would like to use BITS to do the transfers but it appears this only works with HTTP. I could switch to HTTP but I currently check what needs to be downloaded by comparing file sizes and dates on the server and the local cache. This does not seem possible using HTTP.
Is there a way to use BITS and FTP? Or is there a way to check what needs downloading with HTTP?
I have complete control over the servers. They currently run Linux and OpenSSH to facilitate the transfers. I'm using VB and .NET framework 4.0 for the application.
Thanks.
You can use a System.Net.HttpWebRequest to the web URL with a request method of "HEAD". You can then get a System.Net.HttpWebResponse and check the ContentLength and LastModified properties of the response to compare to the local cache.
e.g.
dim request as System.Net.HttpWebRequest
request=System.Net.HttpWebRequest.Create("http://...")
request.Method="HEAD"
dim response as System.Net.HttpWebResponse=request.GetResponse
dim fileLength as integer=response.ContentLength
dim fileDate as datetime=response.LastModified
obviously, you need to trap for exceptions as the GetResponse might not like it if the file isn't there or the server isn't available, etc.
Hope this helps, Regards, Denver
I'm creating a WCF (C#, VS2010) for my silverlight app, I'm trying to create a file on my remote server (where WCF exists), but I get an unknown error, I just get "Server not found" error in WCF function complete exception message, I use following codes to create a file on my remote server (I use a VDS, so I think I don't have permission problems, I use remote desktop on my server)
using (StreamWriter outfile =
new StreamWriter("mytest.htm"))
{
outfile.Write(body);
}
what is going wrong here? is it possible that I have permission problems? I run my WCF on local system and it creates file successfully, but there is no luck when it is uploaded to remote server
should I use Server.MapPath for giving address of my file?
Please use this:
System.Net.FileWebRequest request = (System.Net.FileWebRequest)System.Net.FileWebRequest.CreateDefault(new Uri("\\\\remotelocation\\MyText.txt"));
request.Method = "POST";
Stream requestStream = request.GetRequestStream();
byte [] fileContents = Encoding.UTF8.GetBytes("test_content");
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
I'm trying to use the DeploymentCatalog to load my service implementations by MEF. I have the implementation in a single xap. when I use the following code to download it , every thing is ok :
var catalog = new DeploymentCatalog("MyXap.xap");
catalog.DownloadAsync();
I put my xap on a remote server , say on http://ip:90/Myxap.xap, when I write the same code but with the uri , it throws a deployment exception:
var catalog = new DeploymentCatalog(new Uri("http://ip:90/MyXap.xap",UriKind.Absolute));catalog.DownloadAsync();
Any help .
Thanks in advance ...
If the XAP you are trying to download is hosted at a different domain (or different port, I think) than your Silverlight App is, you will need a cross domain policy file on the site that hosts your XAP to allow your Silverlight App to access it.
If that's not the problem, you'll need to provide more information. Edit your question to include the full text of the deployment exception you get.