C
chike_oji
Hello all,
please I need help with an a web app that I
am developing. I am using .NET 2.0, VS 2005, IIS 6.0, Windows Server
2003 Standard Edition sp2
The application was deployed our server in my country
and it was accessible over the internet from our clients.
Later due to QOS issues, we decided to host the app
on our dedicated server in the UK.
I re-deployed the app on the server via remote access means and
tested it out on the local machine using the hostname "localhost".
It worked but anytime I try to access it from over the internet from
another machine in
a different geographical location, the default.aspx page works,
displaying its content but the
main page (waspprovider.aspx) that sends data from the database as a
HttpResponse object,
doesn't display anything but the page gets hit.
The contents of the working Default.aspx page is as follows:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Welcome to Visafone web content provision web application.</
div>
</form>
</body>
</html>
The content of the waspprovider.aspx.cs page is as follows:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System .Collections.Generic ;
using System.Data.SqlClient;
using A3MessageProcessing;
using A3MessageTransaction;
//using Guinnesspromo;
public partial class Rawurl : System.Web.UI.Page
{
private string _shortcode =
System.Configuration.ConfigurationManager.AppSettings["shortcode"],
_username =
System.Configuration.ConfigurationManager.AppSettings["username"] ,
_password =
System.Configuration.ConfigurationManager.AppSettings["password"],
_port =
System.Configuration.ConfigurationManager.AppSettings["port"],
servicename = null ;
public string shortcode
{
get { return _shortcode; }
}
public string username
{
get { return _username; }
}
public string password
{
get { return _password; }
}
public string port
{
get { return _port; }
}
string responseString = null ;
protected void Page_Load(object sender, EventArgs e)
{
try
{
Page.Title = "";
TransactionInfo tif = new TransactionInfo();
responseString = "Thank you... [Iconcepts TECH.]";
//if (Page.Request.RawUrl.Contains("sms_src_addr=") &&
Page.Request.RawUrl.Contains("sms_dest_addr=") &&
Page.Request.RawUrl.Contains("sms_text="))
if (Page.Request.RawUrl.Contains("sms_src_addr=") &&
Page.Request.RawUrl.Contains("sms_text="))
{
NameValueCollection queryString =
Page.Request.QueryString;
// from here ...
if (Page.Request.RawUrl.Contains("username="+username ) &&
Page.Request.RawUrl.Contains("password="+password))
{
//string gsm = getQueryStringValue("sms_dest_addr",
queryString).Trim();
string gsm = "xxxxx;//Hard code the sms_dest_addr
specifically for visafone/UCIas they requested not to see that
querystring.
if (gsm == shortcode)
{
// Correct format analysis
tif.m_shortCode = gsm;
tif.m_msisdn = getQueryStringValue("sms_src_addr",
queryString);
//tif.m_destAddressIn =
getQueryStringValue("sms_dest_addr", queryString);
tif.m_destAddressIn = gsm;
tif.m_bodyIn = getQueryStringValue("sms_text",
queryString);
string mid = getQueryStringValue("sms_id",
queryString);
tif.m_dateIn = DateTime.Now.ToString("dd-MM-yyyy
HH:mm:ss");
//tif.m_destAddressIn = gsm; This line is a
repetition and duplication of effort. Consider deleting this line.
//bool toGlo = SendGLOMessage(tif, mid, out
responseString);
tif.m_operatorID = OperatorID.Globacom;//This was
left till the creation of a Visafone element in the Enum. Doesn't
cause any problems.
try
{
TransactionInfoProcessor smsobject = null;
smsobject = new Iconceptservices();
if (smsobject != null)
smsobject.processTransactionInfo(tif);
// tif.m_bodyOut = "Thank you for
playing ...";
bool bl = LogToDatabase(tif);
}
catch (Exception er)
{
}
responseString = tif.m_bodyOut;
}
else
{
responseString = "Invalid Login Credentials! [" +
DateTime.Now.ToString() + "Iconcepts";
}
}
else
{
responseString = "Wrong msg format. Port is still
alive! [" + DateTime.Now.ToString() + "Iconcepts";
}
}
//Make sure the response string length is not greater than
160.
if (responseString.Length > 160)
{
responseString = responseString.Substring(0,
160);
}
//Trying to implement
// Obtain a response object
HttpResponse httpresponse = Page.Response;
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
// Get a response stream and write the response to it
// httpresponse.ContentLength64 = buffer.Length;
httpresponse.ContentType = "text/plain";
//Trying to implement returning error 404 if there is no
content
if (responseString.StartsWith("no content for the day"))
{
httpresponse.StatusCode = 404; httpresponse.Status =
"404 Not Found";
httpresponse.OutputStream.Write(buffer, 0,
buffer.Length);
httpresponse.Flush(); httpresponse.Close();
}
else//everything is ok here.i.e content is returned and
client billed.
{
httpresponse.OutputStream.Write(buffer, 0,
buffer.Length);
httpresponse.Flush(); httpresponse.Close();
}
}
catch (Exception exception)
{
//Console.WriteLine(exception.Message);
//Console.WriteLine(exception.StackTrace);
}
finally
{
// do neccessary task here ...
}
return;
}
private static String getQueryStringValue(String keyName,
NameValueCollection queryString)
{
String keyValue = null;
// Get each header and display each value
foreach (String key in queryString.AllKeys)
{
if (keyName.ToLower().CompareTo(key.ToLower()) == 0)
{
keyValue = queryString[key];
}
}
return keyValue;
}
// logging sms messages to mg_transaction_log for persistent
reference ...
private static bool LogToDatabase(TransactionInfo tif)
{
Dictionary<string, Procedure_Values> dictionary = new
Dictionary<string, Procedure_Values>();
Procedure_Values procedure = null;
procedure = new Procedure_Values();
SqlParameter operatorID = null;
procedure.pname = "operatorID";
procedure.sqlparameter = operatorID;
procedure.sqldbtype = SqlDbType.VarChar;
procedure.svalue = "VISAFONE";
procedure.size = 25;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter msisdn = null;
procedure.pname = "msisdn";
procedure.sqlparameter = msisdn;
procedure.sqldbtype = SqlDbType.VarChar;
procedure.svalue = tif.m_msisdn;
procedure.size = 15;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter shortcode = null;
procedure.pname = "shortcode";
procedure.sqlparameter = shortcode;
procedure.sqldbtype = SqlDbType.VarChar;
procedure.svalue = tif.m_shortCode;
procedure.size = 50;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter servicename = null;
procedure.pname = "servicename";
procedure.sqlparameter = servicename;
procedure.sqldbtype = SqlDbType.VarChar;
procedure.svalue = tif.m_idOut;
procedure.size = 15;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter log_date = null;
procedure.pname = "log_date";
procedure.sqlparameter = log_date;
procedure.sqldbtype = SqlDbType.DateTime;
procedure.dvalue = DateTime.Now;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter
..
..
..
.....
I wanted to add that the OS on the UK server is
Microsoft Server 2003 Standard edition Service Pack 2
and it has IIS 6.0 webserver running on it.
Thanks.
Regards,
Chike
please I need help with an a web app that I
am developing. I am using .NET 2.0, VS 2005, IIS 6.0, Windows Server
2003 Standard Edition sp2
The application was deployed our server in my country
and it was accessible over the internet from our clients.
Later due to QOS issues, we decided to host the app
on our dedicated server in the UK.
I re-deployed the app on the server via remote access means and
tested it out on the local machine using the hostname "localhost".
It worked but anytime I try to access it from over the internet from
another machine in
a different geographical location, the default.aspx page works,
displaying its content but the
main page (waspprovider.aspx) that sends data from the database as a
HttpResponse object,
doesn't display anything but the page gets hit.
The contents of the working Default.aspx page is as follows:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Welcome to Visafone web content provision web application.</
div>
</form>
</body>
</html>
The content of the waspprovider.aspx.cs page is as follows:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System .Collections.Generic ;
using System.Data.SqlClient;
using A3MessageProcessing;
using A3MessageTransaction;
//using Guinnesspromo;
public partial class Rawurl : System.Web.UI.Page
{
private string _shortcode =
System.Configuration.ConfigurationManager.AppSettings["shortcode"],
_username =
System.Configuration.ConfigurationManager.AppSettings["username"] ,
_password =
System.Configuration.ConfigurationManager.AppSettings["password"],
_port =
System.Configuration.ConfigurationManager.AppSettings["port"],
servicename = null ;
public string shortcode
{
get { return _shortcode; }
}
public string username
{
get { return _username; }
}
public string password
{
get { return _password; }
}
public string port
{
get { return _port; }
}
string responseString = null ;
protected void Page_Load(object sender, EventArgs e)
{
try
{
Page.Title = "";
TransactionInfo tif = new TransactionInfo();
responseString = "Thank you... [Iconcepts TECH.]";
//if (Page.Request.RawUrl.Contains("sms_src_addr=") &&
Page.Request.RawUrl.Contains("sms_dest_addr=") &&
Page.Request.RawUrl.Contains("sms_text="))
if (Page.Request.RawUrl.Contains("sms_src_addr=") &&
Page.Request.RawUrl.Contains("sms_text="))
{
NameValueCollection queryString =
Page.Request.QueryString;
// from here ...
if (Page.Request.RawUrl.Contains("username="+username ) &&
Page.Request.RawUrl.Contains("password="+password))
{
//string gsm = getQueryStringValue("sms_dest_addr",
queryString).Trim();
string gsm = "xxxxx;//Hard code the sms_dest_addr
specifically for visafone/UCIas they requested not to see that
querystring.
if (gsm == shortcode)
{
// Correct format analysis
tif.m_shortCode = gsm;
tif.m_msisdn = getQueryStringValue("sms_src_addr",
queryString);
//tif.m_destAddressIn =
getQueryStringValue("sms_dest_addr", queryString);
tif.m_destAddressIn = gsm;
tif.m_bodyIn = getQueryStringValue("sms_text",
queryString);
string mid = getQueryStringValue("sms_id",
queryString);
tif.m_dateIn = DateTime.Now.ToString("dd-MM-yyyy
HH:mm:ss");
//tif.m_destAddressIn = gsm; This line is a
repetition and duplication of effort. Consider deleting this line.
//bool toGlo = SendGLOMessage(tif, mid, out
responseString);
tif.m_operatorID = OperatorID.Globacom;//This was
left till the creation of a Visafone element in the Enum. Doesn't
cause any problems.
try
{
TransactionInfoProcessor smsobject = null;
smsobject = new Iconceptservices();
if (smsobject != null)
smsobject.processTransactionInfo(tif);
// tif.m_bodyOut = "Thank you for
playing ...";
bool bl = LogToDatabase(tif);
}
catch (Exception er)
{
}
responseString = tif.m_bodyOut;
}
else
{
responseString = "Invalid Login Credentials! [" +
DateTime.Now.ToString() + "Iconcepts";
}
}
else
{
responseString = "Wrong msg format. Port is still
alive! [" + DateTime.Now.ToString() + "Iconcepts";
}
}
//Make sure the response string length is not greater than
160.
if (responseString.Length > 160)
{
responseString = responseString.Substring(0,
160);
}
//Trying to implement
// Obtain a response object
HttpResponse httpresponse = Page.Response;
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
// Get a response stream and write the response to it
// httpresponse.ContentLength64 = buffer.Length;
httpresponse.ContentType = "text/plain";
//Trying to implement returning error 404 if there is no
content
if (responseString.StartsWith("no content for the day"))
{
httpresponse.StatusCode = 404; httpresponse.Status =
"404 Not Found";
httpresponse.OutputStream.Write(buffer, 0,
buffer.Length);
httpresponse.Flush(); httpresponse.Close();
}
else//everything is ok here.i.e content is returned and
client billed.
{
httpresponse.OutputStream.Write(buffer, 0,
buffer.Length);
httpresponse.Flush(); httpresponse.Close();
}
}
catch (Exception exception)
{
//Console.WriteLine(exception.Message);
//Console.WriteLine(exception.StackTrace);
}
finally
{
// do neccessary task here ...
}
return;
}
private static String getQueryStringValue(String keyName,
NameValueCollection queryString)
{
String keyValue = null;
// Get each header and display each value
foreach (String key in queryString.AllKeys)
{
if (keyName.ToLower().CompareTo(key.ToLower()) == 0)
{
keyValue = queryString[key];
}
}
return keyValue;
}
// logging sms messages to mg_transaction_log for persistent
reference ...
private static bool LogToDatabase(TransactionInfo tif)
{
Dictionary<string, Procedure_Values> dictionary = new
Dictionary<string, Procedure_Values>();
Procedure_Values procedure = null;
procedure = new Procedure_Values();
SqlParameter operatorID = null;
procedure.pname = "operatorID";
procedure.sqlparameter = operatorID;
procedure.sqldbtype = SqlDbType.VarChar;
procedure.svalue = "VISAFONE";
procedure.size = 25;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter msisdn = null;
procedure.pname = "msisdn";
procedure.sqlparameter = msisdn;
procedure.sqldbtype = SqlDbType.VarChar;
procedure.svalue = tif.m_msisdn;
procedure.size = 15;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter shortcode = null;
procedure.pname = "shortcode";
procedure.sqlparameter = shortcode;
procedure.sqldbtype = SqlDbType.VarChar;
procedure.svalue = tif.m_shortCode;
procedure.size = 50;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter servicename = null;
procedure.pname = "servicename";
procedure.sqlparameter = servicename;
procedure.sqldbtype = SqlDbType.VarChar;
procedure.svalue = tif.m_idOut;
procedure.size = 15;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter log_date = null;
procedure.pname = "log_date";
procedure.sqlparameter = log_date;
procedure.sqldbtype = SqlDbType.DateTime;
procedure.dvalue = DateTime.Now;
procedure.direction = ParameterDirection.Input;
dictionary.Add(procedure.pname, procedure);
procedure = new Procedure_Values();
SqlParameter
..
..
..
.....
I wanted to add that the OS on the UK server is
Microsoft Server 2003 Standard edition Service Pack 2
and it has IIS 6.0 webserver running on it.
Thanks.
Regards,
Chike