My sms page is not redirecting

Posted by Shanthosh2110 under ASP.NET on 1/11/2012 | Points: 10 | Views : 1087 | Status : [Member] | Replies : 2
Hi,

I have used the below to redirect my login page to next send sms page but it is not redirecting if any one find any mistake in the below given code pls reply

public void connect()
{
ckuser = Session["id"].ToString();
ckpass = Session["pw"].ToString();

try
{
this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com/auth.cl");

this.req.CookieContainer = new CookieContainer();
this.req.AllowAutoRedirect = false;
this.req.Method = "POST";
this.req.ContentType = "application/x-www-form-urlencoded";
this.strNewValue = "username=" + ckuser + "&password=" + ckpass;
this.req.ContentLength = this.strNewValue.Length;
StreamWriter writer = new StreamWriter(this.req.GetRequestStream(), Encoding.ASCII);
writer.Write(this.strNewValue);
writer.Close();
this.response = (HttpWebResponse)this.req.GetResponse();
this.cookieCntr = this.req.CookieContainer;
this.response.Close();
this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com//jsp/InstantSMS.jsp?val=0");
this.req.CookieContainer = this.cookieCntr;
this.req.Method = "GET";
this.response = (HttpWebResponse)this.req.GetResponse();
responseee = new StreamReader(this.response.GetResponseStream()).ReadToEnd();
int index = Regex.Match(responseee, "custf").Index;
responseee = responseee.Substring(index, 0x12);
responseee = responseee.Replace("\"", "").Replace(">", "").Trim();
this.response.Close();

pnlsend.Visible = true;
lblErrormsg.Text = "connected";
}
catch (Exception)
{
lblErrormsg.Text = "Error connecting to the server...";
Session["error"] = "Error connecting to the server...";
Server.Transfer("Default.aspx");
}
}

Thanks.

shanthosh.s


Responses

Posted by: Ogipansrk on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hello,

Write your code outside the constructor.
It will solve your issue.


Regards,
Ogipansrk


Shanthosh2110, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 1/12/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
What is this code about?
Are you using way2sms site for sending free sms from your site ?

If so, is it possible to do so?
please give more information in this regard.

I like to send free sms from website using way2sms site.

Shanthosh2110, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response