Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Retrieving User Information

Reply
Thread Tools

Retrieving User Information

 
 
Dave
Guest
Posts: n/a
 
      08-04-2010
I'm trying to adjust my default.aspx page to see if the user is
accessing it from a smart phone. In a previous post someone suggested
using Page.Request.UserAgent. After reviewing the possibilities I
added the below code to my Page_Load.

The below runs fine in Visual Studio. When moving it out to my Web
Server sitting in the DMZ none of the varialbes are returning. No
errors are being generated and the Stored Procedure doesn't even show
up in Profiler. I've tried dropping everything and just putting a
Response.Write("Test")....It's as if the Page_Load isn't even firing.
It should be noted that this is the home page in the web. Any
thoughts or suggested?

Thanks

*****CODE****

namespace Web
{
public partial class _default : System.Web.UI.Page
{
ReportError rE = new ReportError();
protected void Page_Load(object sender, EventArgs e)
{
try
{
rE.Error = "";

string a = Page.Request.UserAgent.ToString();
string b = Page.Request.UserHostAddress.ToString();
string c = Environment.MachineName.ToString();

string strConnection =
ConfigurationManager.ConnectionStrings["VortexConnectionString"].ConnectionString;
using (SqlConnection connection = new
SqlConnection(strConnection))
{
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = "UserAgentInfo_INSERT";

command.Parameters.AddWithValue("@UserAgent",
a.ToString());

command.Parameters.AddWithValue("@UserHostAddress" , b.ToString());
command.Parameters.AddWithValue("@UserHostName",
c.ToString());

command.Parameters.Add("@ErrorCode",
SqlDbType.VarChar, 50);
command.Parameters["@ErrorCode"].Direction =
ParameterDirection.Output;
command.Parameters.Add("@ErrorMessage",
SqlDbType.VarChar, 500);
command.Parameters["@ErrorMessage"].Direction =
ParameterDirection.Output;

command.CommandType = CommandType.StoredProcedure;

connection.Open();
command.ExecuteNonQuery();

connection.Close();
}

}
catch (Exception ex)
{
rE.Error = ex.Message;
}
}
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving mailbox information through ADSI =?Utf-8?B?ZG90bmV0dGVzdGVy?= ASP .Net 0 08-31-2005 07:37 PM
Retrieving User Information - IIS 6.0 CGI Single Sign On Geoffry Smith Perl Misc 2 05-04-2005 03:11 PM
Retrieving state information from a middle tier =?Utf-8?B?SWFuIFdpbGxpYW1zb24=?= ASP .Net 6 02-25-2005 10:03 PM
Need Microsoft Help: Session object retrieving another user's Session information Boban Dragojlovic ASP .Net 2 04-19-2004 06:45 PM
Retrieving information from AssemblyInfo.vb Rob ASP .Net 2 12-17-2003 12:58 PM



Advertisments