The remote server returned an error: (403) forbidden.

Source: Internet
Author: User
The remote server returned an error: (403) forbidden. Posted by amruta Patil in C #. Net on 02-feb-11 AM

Hello .......

I m developing a C # application in ASP. Net of sending SMS using way2sms when I open ing http://www.way2sms.com/URL in code through HTTP protocol I m getting error at line

Httpwebresponse response = (httpwebresponse) request. getresponse ();

Error: the remote server returned an error: (403) forbidden.

My application code is:

Httpwebrequest request = (httpwebrequest) webrequest. Create ("http://wwwk.way2sms.com/auth.cl ");

Request. keepalive = false;

Request. Timeout = 20000;

Request. Credentials = new networkcredential ("172.23.51.111", "8082 ");

// Request. connectiongroupname = "172.23.51.111 ";

 

 

 

Byte [] bytearray = encoding. utf8.getbytes (content );

Cookiecontainer cookies = new cookiecontainer ();

Request. cookiecontainer = cookies;

Request. useragent = "Mozilla/5.0 ";

// Request. useragent = "Mozilla/5.0 (windows; U; Windows NT 6.0; en-US; RV: 1.9.0.5) Gecko/2008120122 Firefox/3.0.5 ";

 

 

 

Request. contentlength = bytearray. length;

Request. contenttype = "application/X-WWW-form-urlencoded ";

Request. Accept = "*/*";

Request. Referer = "http://wwwk.way2sms.com//entry.jsp ";

Request. method = "Post ";

Stream datastream = request. getrequeststream ();

Datastream. Write (bytearray, 0, bytearray. Length );

Datastream. Close ();

Httpwebresponse response = (httpwebresponse) request. getresponse ();

 
Thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.