.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Basket with Cookie Manager

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :ASP.Net
Hi, I'm trying to place products in a basket with cookies,I created this procedure:private void AggiungiShoppingCart(int ProductID, int quantita) { try { //int dayexpires = _aziendabusiness.GetDayProductMoreVendor(); if (Request.Cookies["ShoppingCart"] == null) { HttpCookie cookieshopping = new HttpCookie("ShoppingCart"); cookieshopping.Expires = DateTime.Now.AddDays(1); cookieshopping.Value = "Prodotto" + quantita + " " + ProductID.ToString(); Response.Cookies.Add(cookieshopping); } else { char[] sep = { ',' }; HttpCookie cookieshopping = (HttpCookie)Request.Cookies["ShoppingCart"]; cookieshopping.Expires = DateTime.Now.AddDays(1); string idprod = cookieshopping.Value.ToString(); string[] arrcookieshopping = idprod.Split(sep); for (int i = 0; i < arrcookieshopping.Length; i++) { if (arrcookieshopping[i].Split(' ')[1].ToString().Trim() == ProductID.ToString().Trim()) {

View Complete Post

More Related Resource Links

Remove item (Cookie) from basket (Cookie Collection)

Hi I am busy building a shopping cart with cookies. I have datalist which I populate from the cookies with a delete button next to each cookie Here is the code:public partial class Basket_Checkout : System.Web.UI.Page { //List<ProductItemObject> ProductsList = new List<ProductItemObject>(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindList(); } } private void BindList() { dlstProducts.DataSource = null; dlstProducts.DataSource = ProductsList(); dlstProducts.DataBind(); } public List<ProductItemObject> ProductsList() { StringBuilder sb = new StringBuilder(); int loop1, loop2; HttpCookieCollection MyCookieColl; HttpCookie MyCookie; MyCookieColl = Request.Cookies; // Capture all cookie names into a string array. String[] arr1 = MyCookieColl.AllKeys; // Grab individual cookie objects by cookie name. List<ProductItemObject> CurrentBasket = new List<ProductItemObject>(); for (loop1 = 0; loop1 < arr1.Length; loop1++) { ProductItemObject item = new ProductItemObject(); MyCo

browser gives jibberish when State manager (sql) is turned on


Hi all, we're testing our web app with a state manager so that we can do distributed rollouts. We're not getting any errors, but we are getting jibberish returned for every page request. 

(it won't even let me paste it in here)

HOw do I get it to serve the pages normally?


Getting users list reporting to manager from LDAP


Dear All,

I need to get list of users reporting to a particular manager from the Active directory.

In the active directory there is manager property with contains the data in the following way.


Please help me in building the filter condition.

I am using the following

pUserName="Gegore Lid";

strSearch = "(&(objectClass=user)(objectCategory=user)((Manager cn=" + pUserName + "))";

DirectorySearcher dSearcher = new DirectorySearcher(dEntry, strSearch);

            //Account properites to load
            string[] arrPropertiesToLoad = { "displayName", "department", "manager", "sAMAccountName", "EmployeeNumber", "Title" };

          SearchResultCollection sResultColl = dSearcher.FindAll();

 the above code is not returning any result.

Please help me in this.



Getting list of users reporting from specific Manager from Active Directory


Dear All,

I am have requirement like displaying all the user information reporting to specific manager from Active Directory.

Please help me regarding this.



Going Places: How Connection Manager Connects


Marcus Perryman explains the correct use of Connection Manager when a Windows Mobile application requires network data.

Marcus Perryman

MSDN Magazine December 2008

Aero Glass: Create Special Effects With The Desktop Window Manager


In this article we introduce the Desktop Window Manager, the new interface that manages how windows are rendered on the Windows Vista desktop.

Ron Fosner

MSDN Magazine April 2007

.NET Matters: Restart Manager and Generic Method Compilation


This month Stephen Toub answers questions pertaining to the Windows Vista Restart Manager API and generic method compilation.

Stephen Toub

MSDN Magazine April 2007

Authorize It: Use Role-Based Security in Your Middle Tier .NET Apps with Authorization Manager


Authorization Manager in Windows Server 2003 represents a significant improvement in the administration of role-based security, making it more scalable, flexible, and easier to implement. Using Authorization Manager, you can define roles and the tasks those roles can perform. You can nest roles to inherit characteristics from other roles, and you can define application groups. In addition, Authorization Manager lets you use scripts to modify permissions dynamically, and it allows you to wrap your security logic in a security policy that can be stored in Active Directory. Authorization Manager also includes an easy-to-use API for running access checks. The author discusses all of these topics and demonstrates them with a working sample.

Keith Brown

MSDN Magazine November 2003

COM+: Create a Compensating Resource Manager to Extend Your App's Transactional Features


A Compensating Resource Manager (CRM) is any COM+ object that uses the CRM facility provided by COM+, a set of tools that make it simple to create a custom resource manager for business scenarios that require handling some non-database operation (such as generating a file) as part of a transaction. This article provides an overview of transaction processing, distributed transactions, and the two-phase commit protocol for transactions. Also covered are the implementation and configuration of a CRM.

Alan Gordon

MSDN Magazine March 2001

Web Security: Part 2: Introducing the Web Application Manager, Client Authentication Options, and Pr


This article, the second of two parts, continues coverage of Web security for Windows. It introduces the Web Application Manager in IIS that allows Web processes to be isolated, decreasing the security risk associated with running in a logon session. The article then picks up where Part One left off-it discusses authentication methods such as basic authentication, digest authentication, integrated Windows authentication, and anonymous logons, and the benefits and drawbacks of each.

Keith Brown

MSDN Magazine July 2000

Adding a cookie to a response.redirect vs. httpWebRequest


Hello, I will try to be as clear as I can be.  I'm sure this question has been asked but I can't find a suitable answer for this particular situation.

I need to be able to redirect the browser to a new 3rd party page while at the same time supplying a cookie required for some form of authentication on the 3rd party site.

I have managed to get this to work in the following manner:


'SessionID is predetermined by another HttpWebRequest/Response  

Dim sessionCookie As New Cookie("ezproxy", sessionID.Substring(1), "/", ".someother.site")

Dim CookieJar As New CookieContainer


rRequest = HttpWebRequest.Create("where I want to go")

rRequest.CookieContainer = CookieJar

rRequest.Method = "GET"


'Make the request and get the response.

rResponse = rRequest.GetResponse()


'Save cookie(s)

If (rResponse.Cookies.Count <> 0) Then

For Each cook

Configure a module through IIS Manager?


I've developed a custom module with a custom configuration section.  Is there a way to create a plug-in or module so IIS Manager can manage the module?  I'm looking for the ability to enable or disable it by site as well as setup various configuration properties.

Why is ASP.NET appending "\" to the beginning and end of a cookie value?


Here's what I'm seeing in FireFox when viewing a Facebook generated cookie coming from facebook:

But when I go and get this cookie and shove it into an HttpCookie object, now it's appending this stupid "\" to the beginning and end causing me all sorts of issues..one with the first key/value pair and then the uid ends up containing a "\" after the uid value (WHY would it be appending this crap?!?!?):

my code:

string facebookCookieName = "fbs_" + ConfigUtil.GetAppConfigSetting("PayPalClientID");

            // Check for an existing session
            HttpCookie facebookAuthCookie = HttpContext.Current.Request.Cookies[facebookCookieName];

string userID = facebookAuthCookie["uid"];
            string accessToken = facebookAuthCookie["\"access_token"];

CRUD Operation should be Part of BO or Service/Manager Classes?



I am developing an application which has a general structure similar to what Scott has described at http://nhibernateasp.codeplex.com

Thanks to Scott for developing such a nice architecture which can be used for most of the projects!

It uses Service Layer which contains service classes (like Product Service) which actually talk to the repository layer (ProductRepository) and these service classes are responsible for CRUD operations while the BO (Product) contains just the data and the validation methods.

As I have read, in OO design, you should design a class which contain both data and behavior, in which case, the BO (Product) should be responsible for doing its own CRUD and it should not be a responsibility of Service classes.

Which approach you think is better design and what could be the reasons?

Any help is this regard is appreiciated.




How Can I Change Cookie value?

 Hi Friends, I use cookie to change the language of my website. When I click a LinkButton to change the language for first time it works but the other button doesn't work to change the language . I should delete cookie to change the language.     <asp:LinkButton ID="LinkButtonEn" runat="server" CommandArgument="en-US" OnCommand="LnkLang_Command" Text="English"></asp:LinkButton>        protected void LnkLang_Command(object sender, CommandEventArgs e)    {        Response.Cookies["mylang"].Value = "";        Response.Cookies["mylang"].Value = e.CommandArgument.ToString();        Response.Redirect("~/Default.aspx");    } thanks in advance, sepid

How to set Host's Domain Manager in a created AppDomain

I am not sure if this is possible but I would want something similar to loading the Host's domain manager to my new AppDomain. There is no Domain Manager for a newly created AppDomain. Owing to this many of my subsequent call fails. For example if I make a call to "Assembly.GetEntryAssembly" it returns null in the new AppDomain. To workaround this I will have to call "AppDomain.ExecuteAssembly("entryassembly")" in my created AppDomain. I actually do not have a need to do this in my application. Similarly there are other calls such as "ScriptEngine.GetSearchPaths". This again does not return the expected search paths in my new AppDomain. Again if I perform "AppDomain.ExecuteAssembly("entryassembly")" then the expected search path is returned. So in short a domain manager is created in my new AppDomain only when i execute the entry assembly in my new AppDomain; which internally provides me a domain manager similar to the Host's domain Manager (as i execute the same entry assembly). Is there a way to load the Host's domain manager without executing any assembly in my new AppDomain. I am using VS 2008, .Net Framework 2.0.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend