Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > HttpContext.Current.Profile problem using Asp.net 2.0

Reply
Thread Tools

HttpContext.Current.Profile problem using Asp.net 2.0

 
 
Rodusa
Guest
Posts: n/a
 
      08-30-2005
I am trying to replace cookies with the new "Asp.net 2.0 profiles" in
my shopping cart application, but I am having trouble to access profile
properties using HttpContext.Current.Profile. I can access any other
property property of this class from a regular aspx page, but not from
inside the class itself.

This is the piece of the code that I am trying to get to work which can
also be located at the bottom of the page, but so far just weariness.
Any help at this point would be really appreciated.

// WRITE TO PROFILE
HttpContext.Current.Profile.CurrentBasketInfo.Cart Items = dtSession;

// MY WEB.CONFIG
<profile defaultProvider="SqlProvider">
<providers>
<clear/>
<add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider"
connectionStringName="myconnection" applicationName="/"
description="SqlProfileProvider for SampleApplication"/>
</providers>
<properties>
<add name="Name"/>
<add name="SelectedShippingAddress" type="MyCart.Address"/>
<add name="CurrentBasketInfo" type="MyCart.Basket"/>
</properties>
</profile>



namespace MyCart
{
public class Basket: Product
{

private Address _ShippingAddress;
public Address SelectedShippingAddress
{
get { return _ShippingAddress; }
set { _ShippingAddress = value; }
}

private Contacts _ContactAddress;
public Contacts ContactAddress
{
get { return _ContactAddress; }
set { _ContactAddress = value; }
}

private string _CreditCardType;
public string CreditCardType
{
get { return _CreditCardType; }
set { _CreditCardType = value; }
}

private string _CreditCardNumber;
public string CreditCardNumber
{
get { return _CreditCardNumber; }
set { _CreditCardNumber = value; }
}

private string _CreditCardExpirationDate;
public string CreditCardExpirationDate
{
get { return _CreditCardExpirationDate; }
set { _CreditCardExpirationDate = value; }
}

private string _POnumber;
public string POnumber
{
get { return _POnumber; }
set { _POnumber = value; }
}

private string _BasketItems;
public string BasketItems
{
get { return _BasketItems; }
set { _BasketItems = value; }
}

private string _total;
public string total
{
get { return _total; }
set { _total = value; }
}

private DataTable _CartItems;
public DataTable CartItems
{
get { return _CartItems; }
set { _CartItems = value; }
}


public void AddItemToBasket(string item_sku, int qty)
{
// Checks new item Information in Database
string sql = "select * from product where item_sku='" + item_sku + "'";
SqlDataReader r = SqlServer.SearchSQL(sql, "myconnection");

// Gets Current Basket Session DataTable
DataTable dtSession = (DataTable)HttpContext.Current.Session["basket"];

if (r.Read())
{
if (dtSession!=null) {
DataView dv = new DataView(dtSession);
dv.Sort = "item_sku";
if (dv.Find(item_sku) == -1)
{
DataRow dr = dtSession.NewRow();
dr["key"] = r["product_uid"].ToString();
dr["item_sku"] = r["item_sku"].ToString();
dr["short_desc"] = r["short_desc"].ToString();
dr["qty"] = qty;
dr["price"] = r["price"].ToString();
dr["weight"] = r["weight"].ToString();
dr["weight_unit"] = r["unit_uid"].ToString();
dtSession.Rows.InsertAt(dr, 0);
}

// Writes Cookies
WriteBasketCookies(dtSession); // b= basket cookie
name
// WRITE TO PROFILE
HttpContext.Current.Profile.CurrentBasketInfo.Cart Items =
dtSession;
}

// Adds basket to DataTable Session Variable
HttpContext.Current.Session["basket"] = dtSession;
}

}

Thanks Rod

 
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
Problem using problem reporting Kue2 Windows 64bit 3 01-15-2010 08:07 PM
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM
Problem connecting to https using ZSI (openssl problem) - python2.3 Adil Hasan Python 3 01-29-2004 12:27 AM
Using GetOleDbSchemaTable to get SQL Server Field Description - using pete ASP .Net 1 08-29-2003 10:50 AM
Re: MVP? Index error on nested element using System.xml but NOT using msxml??? William F. Robertson, Jr. ASP .Net 1 06-25-2003 08:08 PM



Advertisments