i have xml data, and i need download to string this. But c# return error like this "Remote adress return error" , but this site is alive and work on my firefox. How to download this data?
My codes:
WebClient x = new WebClient();
string y= x.DownloadString("http://dizilab.com/diziler.xml");
MessageBox.Show(y);
According to a CloudFlare employee who answered this question: cURL - Load a site with CloudFlare protection
If you own the hosted site, you can whitelist your calling domain to allow access, otherwise you "supposedly" have no way of getting around this protection. However, there is a second answer that offers an option that you may find useful if you're familiar with cURL.
Related
For the past year and half i have been using this method:
string page = "";
WebClient WC = new WebClient();
page = WC.DownloadString("http://WWW.LINKEDINPROFILEIWANTTOOPEN.COM");
WC.Dispose();
and i haven't been having any problems, downloading 1000s of profiles a day and then analyzing them with a c# webservice looking through the html for the tags im after. Today i have been presented with an error code of:
"System.Net.WebException: The remote server returned an error: (999)
Request denied."
im guessing linked in has locked me out as they want me to use the api instead. after looking through documentation for the last hour or so it seems as if the api is set up to make your own linkedin app. i just want the standard html or just the basic fields such as name and various positions they have had over time. Also it wants me to log on as me and this just seems unnecessary.
Is the only way i can get round this problem to sign up for the api and then authorize myself and get the fields through the api or does anyone else know a solution to simply download the html for a public profile for which i have the URL
I'm working on a continuing API project. The current issue at hand is to be able to download my data from the AtTask server in precisely the folder structure they exist in on the AtTask servers. I've got the folder creation working nicely; the data types between Document, Document Folder and Document Version seem to be pretty clear. I am a little disillusioned about the fact that extension isn't in the document object (that I have to refer to the document VERSION for that)... but I can see some of the reason for that from a design perspective.
The issue I'm running into now is that I need to get the file content. I originally through from the API documentation that I'd be able to get to the file contents the same way as the documentation recommends uploading it -- through the handle. Unfortunately, neither document nor docv seem to support me accessing the handle except to write a new file.
So that leaves me the "download URL" as the remaining option. If I build the UI strings from the API calls using my browser, I get a URL with https://attaskURL/document/download?ID=xxxx (and can also get the versionID and such). If I paste the url into the browser where I'm logged in to the user interface of AtTask, it works fine and I can download the file. If, instead, I use my C# code to do so, I get the login page returned as a stream for me to download instead of my actual file because I'm not authenicated. I've tried creating a network credential and attaching it to the request with the username and password, but to no avail.
I imagine there's a couple ways to solve this problem -- the easy one being finding a way to "log in" to the download site through code (which doesn't seem to be the usual network credential object in C#) OR find a way to access the file contents through the API.
Appreciate your thoughts!
It looks like you can use the download URL if you put a session id in the URL. The details on getting a session id are here (basically just call login and a session id is returned in JSON):
http://developers.attask.com/api-docs/#Authentication
Then cram it on the end of your document download URL:
https://yourcompany.attask-ondemand.com/document/download?ID=xxxx&sessionID=abc1234
I've given this a quick test and I'm able to access a document.
You can use the downloadURL and a sessionID IF you are not using SAML authentication.
I have tried it both ways and using SAML will redirect you to the login page.
I know, this question has been posted a couple of times before, but I didn't get a clear answer/find a solution. I'm simply using WebClient.DownloadString on a website that uses SSL. Whenever I run my program, I get a "404 not found" error. I tried my program on a website that doesn't use SSL, and it worked perfectly.
Here's my code:
System.Net.WebClient webClient = new System.Net.WebClient();
string webData = webClient.DownloadString("https://example.com?user=" + listBox1.Items[currentIndex]);
I'm trying to make my program compatible with websites that use SSL. Does anyone have any examples on how to do this? Thanks, all help is appreciated.
System.Net.WebClient.DownloadString() does support websites that use SSL. If the server returned a 404 error, that either means that the resource you're requesting doesn't exist or the web server is incorrectly configured to handle SSL requests as you desire.
This is my first time developing this kind of system, so many of these concepts are very new to me. Any and all help would be appreciated. I'll try to sum up what I'm doing as efficiently as possible.
Background: I have a web application running AngularJS with Bootstrap. The app communicates with the server and DB through a web service programmed using C#. On the site, users can upload files and reference them later using direct links. There's no restriction to file type (yet), so just about anything is allowed.
My Goal: Having direct links creates a big security problem for me, since the documents/images are supposed to be private data. What I would prefer to do is validate a user's credentials when the link is clicked, then load the file in the browser using a more generic url path.
--Example--
"mysite.com/attachments/1" ---> (Image)
--instead of--
"mysite.com/data/files/importantImg.jpg"
Where I'm At: Not very far. My first thought was to add a page that sends the server request and receives a file byte stream along with mime type that I can reassemble and present to the user. However, I have no idea if this is possible using a web service that sends JSON requests, nor do I have a clue about how the reassembling process would work client-side.
Like I said, I'll take any and all advice. I'd love to learn more about this subject for future projects as well, but for now I just need to be pointed in the right direction.
Your first thought is correct, for it, you need to use the Response object, and more specifically the AddHeader and Write functions. Of course this will be a different page that will only handle file downloads, so it will be perfectly fine in your JSON web service.
I don't think you want to do this with a web service. Just use a regular IHttpHandler to perform the validation and return the data. So you would have the URL "attachments/1" get rewritten to "attachments/download.ashx?id=1". When you've verified access, write the data to the response stream. You can use the Content Disposition header to set the file name.
I am trying to download a file from rapidshare using System.Net.WebClient in C#.
I wanted to implement authorization using the http header field "Authorization: Basic ".
I do it with the following code:
WebClient.Headers.Add(HttpRequestHeader.Authorization,
"Basic " +
Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(_userPass)));
Problem is that, when i access rapidshare I get a redirected to a sub domoin of rapidshare, this means The problem is that this field, Authorization, (unlike "Cookie") isn't added to the hedear in the second (redirected) request.
This blocks me from authenticating with the server.
How can I make the class pass the authorization header with the redirected request, or is there a better way to pass on authorization?
Is better, "righter" way to do this, maybe with a different library?
All help will be very appreciated.
I think that rapidshare uses cookies to authenticate users and allow direct downloads...
EDIT: I did some digging on google and found a "Simple Rapidshare Download Class". Maybe this would be helpful to you?