Gautam Buddha Temple Varanasi,Varanasi - Buddhist Pilgrimage

Monday, February 27, 2012

How to detect MSISDN from browser headers

        How to detect MSISDN from browser headers  
        Things to note be remember that:  
        1.If the user has come to wap portal on WiFi then you will not receive msisdn.  
        2.User mobile operator has to support the passing of the msisdn in the HTTP      headers.  
        Below is simple code to find msisdn from header.  
        string[] strHeader = Request.Headers.AllKeys;  
       string strMSISDN="";  
       for (int i = 0; i < strHeader.Length; i++)  
         if (strHeader[i].Contains("msisdn") || strHeader[i].ToLower().StartsWith("msisdn", StringComparison.CurrentCultureIgnoreCase) ||strHeader[i].ToLower().EndsWith("msisdn", StringComparison.CurrentCultureIgnoreCase) ||strHeader[i].ToLower().StartsWith("mdn", StringComparison.CurrentCultureIgnoreCase) ||strHeader[i].ToLower().EndsWith("mdn", StringComparison.CurrentCultureIgnoreCase) ||)  
           strMSISDN = Request.Headers[strHeader[i]];  
           if (strMSISDN.Length >= 15)  
             for (int j = 0; j < strHeader.Length; j++)  
               if (strHeader[j].ToLower().StartsWith("mdn", StringComparison.CurrentCultureIgnoreCase) || strHeader[j].ToLower().EndsWith("mdn", StringComparison.CurrentCultureIgnoreCase))  
                 strMSISDN = Request.Headers[strHeader[j]];  
 Thanks & Regards  

Wednesday, February 22, 2012

Create HTTP request and receive response using C#

 Create HTTP request and receive response using C#   
       1.Simple http request  
        Uri objurl = new Uri(url);  
       WebRequest objWebRequest = WebRequest.Create(objurl);  
       WebResponse objWebResponse = objWebRequest.GetResponse();  
       Stream objstream = objWebResponse.GetResponseStream();  
       StreamReader objStreamReader = new StreamReader(objstream);  
       string strHtml = objStreamReader.ReadToEnd();  
        2.HTTP Post request and response  
       HttpWebRequest req = (HttpWebRequest)WebRequest.Create("");        
       req.Method = "POST";  
       req.ContentType = "application/x-www-form-urlencoded";  
       req.Credentials = CredentialCache.DefaultNetworkCredentials;  
       strNewReqValue = strFormValues + "&mssdn=" + msisdn + "&srv=" + Service + "&user=username";  
       req.ContentLength = strNewReqValue.Length;  
       StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);  
       StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());  
       Res = stIn.ReadToEnd();  
       Response = Res.ToString();  

Tuesday, February 21, 2012

How to use stored Procedure with output parameters with ASP.NET,c#

 How to retrieve store procedure output parameter value?I have given a simple code example.  
 I have created a store procedure with output parameter. After that I get it from code behind page of and stored it a variable.    
 private void GetInfo()  
     DALUtility objDALUtility = null;  
     SqlConnection con = null;  
     SqlCommand cmd = null;  
     SqlDataAdapter da = null;  
       objDALUtility = new DBUtility(ConfigurationManager.AppSettings["myconString"]);  
       con = objDALUtility.GetDBConnection();  
       cmd = new SqlCommand();  
       cmd.Connection = con;  
       cmd.CommandType = CommandType.StoredProcedure;  
       cmd.CommandTimeout = 500;  
       cmd.CommandText = "usp_MyInfo";  
       cmd.Parameters.AddWithValue("@Id", strId);  
       cmd.Parameters.AddWithValue("@empName", Convert.ToString(Session["Name"]));        
       cmd.Parameters.Add("@TotalCount", SqlDbType.Int).Direction = ParameterDirection.Output;  
       da = new SqlDataAdapter(cmd);  
       DataSet objDS = new DataSet("MyInfo");  
       int Total = Convert.ToInt32(cmd.Parameters["@TotalCount"].Value);  
 Stored Procedure  
 CREATE Proc [dbo].[usp_MyInfo]  
  @Id int,            
  @Name varchar(50) = null,      
  @Total int = 0 OUTPUT  
 SET @Total = (Select COUNT(Distinct tbl_Logs.ContentId) From tbl_Logs with(nolock)         
  Inner Join tbl_Logs_details with(nolock) on tbl_Logs_details.ContentId = tbl_Logs.ContentId  
  Where id = @id and tbl_Logs_details.ContentId = 2   
 Select @Total as Count