Help me to solve little problem in ASP.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • davidson1
    New Member
    • Feb 2008
    • 144

    Help me to solve little problem in ASP.NET

    Hai friends....the below code is working well for sending sms from VS2008 C# windows Application.... .......but i want the same to work in ASP.NET(vb).... ........can anyone help me....I converted the code and tried but it didnt work........... ............... ............... .....

    In the String uri....under send_to put ur mobile Number......... ......

    CODING:-(c# windows Application)
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.IO;
    namespace internet
    {
        class Program
        {
           static void Main(string[] args)
            {
                String uri = "http://mysmsaddress.net:80/smsc/general/sendsms.jsp
    ?
    userid=nlarsen&password=sam143wi&submit_name=sam&send_to=919894857426&message_type=0&message_text=Hello";
                WebRequest req = WebRequest.Create(uri);
                req.Method = "POST";
                byte[] bytes = System.Text.Encoding.ASCII.GetBytes(uri);
                req.ContentLength = bytes.Length;
                Stream os = req.GetRequestStream();
                os.Write(bytes, 0, bytes.Length);
                os.Close();
                WebResponse res = req.GetResponse();
                if (res == null)
                    Console.WriteLine("Response Null");
                StreamReader sr = new StreamReader(res.GetResponseStream());
                Console.WriteLine("Response :" + sr.ReadLine().ToString());
                Console.ReadLine();
            }
           
        }
    }
    Converted Code:-(vb)
    'The Below Code Should Work For Me.........its not working Now............
    Code:
    Imports System
    
    Imports System.Collections.Generic
    
    Imports System.Linq
    
    Imports System.Text
    
    Imports System.Net
    
    Imports System.IO 
    Shared Sub Main(ByVal args As String())
    
    Dim uri As String = http://mysmsaddress.net:80
    /smsc/general/sendsms.jsp?
    userid=nlarsen&password
    =sam143wi&submit_name=sam&send_to=919894857426&message
    _type=0&message_text=Hello Dim req As WebRequest = WebRequest.Create(uri) 
    req.Method = "POST"
    
    Dim bytes As Byte() = System.Text.Encoding.ASCII.GetBytes(uri) 
    req.ContentLength = bytes.Length
    
    Dim os As Stream = req.GetRequestStream() 
    os.Write(bytes, 0, bytes.Length)
    
    os.Close()
    
    Dim res As WebResponse = req.GetResponse() 
    If res = Nothing Then
    
    Console.WriteLine("Response Null")
    
    End If
    
    Dim sr As New StreamReader(res.GetResponseStream()) 
    Console.WriteLine("Response :" + sr.ReadLine().ToString())
    
    Console.ReadLine()
    
    End Sub

    pl refer Below. for some clarification/............... ......





    Please Help Me...I need for My Project........ ........

    Davidson
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    What is the current output now and what should the output be?

    Comment

    • davidson1
      New Member
      • Feb 2008
      • 144

      #3
      Thank r03..

      this program should send sms from computer to Mobile........t he windows application was working i.e c#(windows) but the web applcation(Asp. net) is not working,,,,,,,, ,,,,,,,,Help me i need the web application should also work.........

      ie) Second code I have Send,,,,,,,,,,, ,

      Davidson....... .......

      Comment

      Working...