Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send SMS with HTML post method

Status
Not open for further replies.

kasius

Programmer
Nov 30, 2010
4
RS
Hi,

I have a problem, and I dont now how to resolve. Please halp. I use ASP.NET 2.0.

I need to submit this from my code, and user dont aloud to see this:


When I do this from my localhost with this code:



Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

' Create a request using a URL that can receive a post.

Dim request As WebRequest = WebRequest.Create("
' Set the Method property of the request to POST.

request.Method = "POST"

' Create POST data and convert it to a byte array.

Dim postData As String = "account=" & Server.UrlEncode("acca_test") & "&password=" & Server.UrlEncode("test_pass") & "&mobile=" & Server.UrlEncode("5454451225") & "&sender=" & Server.UrlEncode("dmpa") & "&text=" & Server.UrlEncode("message_test_message")

Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)

' Set the ContentType property of the WebRequest.

request.ContentType = "application/x-
' Set the ContentLength property of the WebRequest.

request.ContentLength = byteArray.Length

' Get the request stream.

Dim dataStream As Stream = request.GetRequestStream()

' Write the data to the request stream.

dataStream.Write(byteArray, 0, byteArray.Length)

' Close the Stream object.

dataStream.Close()

' Get the response.

Dim response As WebResponse = request.GetResponse()

' Display the status.

' Get the stream containing content returned by the server.

dataStream = response.GetResponseStream()

' Open the stream using a StreamReader for easy access.

Dim reader As New StreamReader(dataStream)

' Read the content.

Dim responseFromServer As String = reader.ReadToEnd()

' Display the content.

TextBox1.Text = responseFromServer

' Clean up the streams.

reader.Close()

dataStream.Close()

response.Close()

End Sub


Everything works fine.

I got response from there server:



<?xml version="1.0"?>

<report>

<status>error</status>

<error_code>7</error_code>

<error_desc>Access denied.</error_desc>

</report>



Because my local IP address is not in there system.



But when I upload my aplication on my server. I am not get any response message, I got an error page:



Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".





What is wrong with my code? Help me please...
 
the error message is:

Server Error in '/' Application.

A socket operation was attempted to an unreachable host 194.0.137.81:15001

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable host 194.0.137.81:15001

Source Error:


Line 24:
Line 25: ' Get the request stream.
Line 26: Dim dataStream As Stream = request.GetRequestStream()
Line 27: ' Write the data to the request stream.
Line 28: dataStream.Write(byteArray, 0, byteArray.Length)

Source File: \\172.21.204.204\webvol20\pv\ysqig4los28oqia\simpa.rs\public_html\index.aspx.vb Line: 26

Stack Trace:


[SocketException (0x2751): A socket operation was attempted to an unreachable host 194.0.137.81:15001]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224

[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +1868309
System.Net.HttpWebRequest.GetRequestStream() +13
_Default.Button1_Click(Object sender, EventArgs e) in \\172.21.204.204\webvol20\pv\ysqig4los28oqia\simpa.rs\public_html\index.aspx.vb:26
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
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) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

And when I change this:


' Create a request using a URL that can receive a post.

Dim request As WebRequest = WebRequest.Create("
' Set the Method property of the request to POST.

request.Method = "POST"

' Create POST data and convert it to a byte array.

Dim postData As String = ":15001?account=" & Server.UrlEncode("acca_test") & "&password=" & Server.UrlEncode("test_pass") & "&mobile=" & Server.UrlEncode("5454451225") & "&sender=" & Server.UrlEncode("dmpa") & "&text=" & Server.UrlEncode("message_test_message")

I got error:

Server Error in '/' Application.

The remote server returned an error: (404) Not Found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (404) Not Found.

Source Error:


Line 30: dataStream.Close()
Line 31: ' Get the response.
Line 32: Dim response As WebResponse = request.GetResponse()
Line 33: ' Display the status.
Line 34: ' Get the stream containing content returned by the server.

Source File: \\172.21.204.204\webvol20\pv\ysqig4los28oqia\simpa.rs\public_html\index.aspx.vb Line: 32

Stack Trace:


[WebException: The remote server returned an error: (404) Not Found.]
System.Net.HttpWebRequest.GetResponse() +5375213
_Default.Button1_Click(Object sender, EventArgs e) in \\172.21.204.204\webvol20\pv\ysqig4los28oqia\simpa.rs\public_html\index.aspx.vb:32
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
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) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Thank you....
 
What he is saying is that you have to see if there is a problem with the host you are trying to connect to. This is not an ASP.NET problem, it is a network/hardware/config problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top