0

I'm trying to get an HttpRequest to post this URL

https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&[email protected]&PASSWORD=What!What!

I've tried using

WebClient rar = new WebClient();
rar.OpenReadAsync(new Uri(@"https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&[email protected]&PASSWORD=What!What!"));

rar.DownloadStringAsync(new Uri(@"https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&[email protected]&PASSWORD=What!What!"));

This is suppose to delete my information on their site, but it's not taking. i'm following this documentation. http://getsatisfaction.com/exzact/topics/how_can_we_delete_old_records_not_manually

and they state that all I have to do is paste the proper URL into a web browser and hit enter and it will work. How would I do this equivalent in c#? Any help would be awesome! Thanks!

2
  • I think you need to escape all of those forward slashes. Commented Apr 7, 2011 at 18:39
  • 2
    @Nick: 1) Why would one need to escape forward slashes. 2) If they were back slashes they would already be escaped by the @ in front of the string. Commented Apr 7, 2011 at 18:40

5 Answers 5

1

Use WebClient.DownloadString instead of DownloadStringAsync. Async indicates asynchronous methods that do not block the current thread.

Sign up to request clarification or add additional context in comments.

Comments

0

Try setting your User-Agent header in your WebClient before you submit it to see if that fixes things.

rar.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")

A lot of web servers are set up to simply ignore requests if the User-Agent header is missing.

Subsequently, you're using HTTPS here so you'll want to set up your ServicePointManager.ServerCertificateValidationCallback as well.

Comments

0

Try to use System.Web classes, for example like this:

        HttpWebRequest req = null;
        HttpWebResponse resp = null;

        try
        {
            req = (HttpWebRequest)HttpWebRequest.Create(url); // enter your url

            req.Method = "post";

            resp = (HttpWebResponse)req.GetResponse();
        }
        catch (Exception)
        {
            throw;
        }

It's example for post method, you can use any other HTTP method like this. Check the documentation.

Comments

0

This isn't a direct answer to your question but check out Hammock for REST

Comments

0
        string uriString = @"https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&[email protected]&PASSWORD=What!What!";
        using (WebClient webClient = new WebClient { Encoding = Encoding.UTF8 })
        {
            try
            {
                string content = webClient.DownloadString(uriString);
                //do stuff with the answer you got back from the site
            }
            catch (Exception exception)
            {
                //handle exceptions
            }
        }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.