当前位置: 首页>>代码示例>>C#>>正文


C# HttpCookieCollection.Remove方法代码示例

本文整理汇总了C#中System.Web.HttpCookieCollection.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# HttpCookieCollection.Remove方法的具体用法?C# HttpCookieCollection.Remove怎么用?C# HttpCookieCollection.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpCookieCollection的用法示例。


在下文中一共展示了HttpCookieCollection.Remove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Set

        private void Set(HttpCookieCollection cookieCollection, HttpCookie cookie)
        {
            if (cookieCollection.AllKeys.Contains(cookie.Name))
            {
                cookieCollection.Remove(cookie.Name);
            }

            cookieCollection.Add(cookie);
        }
开发者ID:ocrenaka,项目名称:Quicksilver,代码行数:9,代码来源:CookieService.cs

示例2: TestCollection

		public void TestCollection ()
		{
			HttpCookieCollection col = new HttpCookieCollection ();
			HttpCookie cookie = new HttpCookie ("cookie", "value");

			col.Add (cookie);

			Assert.AreEqual ("cookie", col["cookie"].Name, "Name is the key");

			col.Remove (cookie.Name);
			Assert.IsNull (col["cookie"], "removal using name");
		}
开发者ID:nobled,项目名称:mono,代码行数:12,代码来源:HttpCookieCollectionTest.cs

示例3: Deny_Unrestricted

		public void Deny_Unrestricted ()
		{
			HttpCookieCollection jar = new HttpCookieCollection ();
			jar.Add (biscuit);
			jar.CopyTo (new object[1], 0);
			Assert.IsNull (jar.GetKey (0), "GetKey");
			jar.Remove ("chocolat");
			jar.Set (biscuit);
			Assert.IsNotNull (jar.Get (0), "Get(int)");
			Assert.IsNull (jar.Get ("chocolat"), "Get(string)");
			Assert.IsNotNull (jar[0], "this[int]");
			Assert.IsNull (jar["chocolat"], "this[string]");
			Assert.AreEqual (1, jar.AllKeys.Length, "AllKeys");
			jar.Clear ();
		}
开发者ID:nobled,项目名称:mono,代码行数:15,代码来源:HttpCookieCollectionCas.cs

示例4: RemoveAuthCookies

        /// <summary>
        ///     Removes the authentication cookies.
        /// </summary>
        /// <param name="cookieCollection">The cookie collection.</param>
        private static void RemoveAuthCookies(HttpCookieCollection cookieCollection) {
            // borrar cualquier cookie con el mismo nombre de la cookie de autenticación
            if (!cookieCollection.AllKeys.Contains(FormsAuthentication.FormsCookieName)) return;
            //
            // obtener nombre definido paral a cookie
            var cookieName = FormsAuthentication.FormsCookieName;
            //
            // recuperar el valor de la cookie antes de eliminarla
            var httpCookie = cookieCollection.Get(cookieName);
            //
            // la cookie existe?
            if (httpCookie == null) return;
            //
            // eliminar la cookie
            cookieCollection.Remove(cookieName);
            //
            // determinar número de cookies en que se guardó el boleto de autenticación
            int numberOfCookies;

            if (!int.TryParse(httpCookie.Value, out numberOfCookies)) return;

            for (var i = 1; i < numberOfCookies; i++) cookieCollection.Remove((cookieName + i));
        }
开发者ID:NemediDev,项目名称:Intercom.Heath,代码行数:27,代码来源:WebAuthenticator.cs

示例5: SetSessionCookiesForPortal

		internal void SetSessionCookiesForPortal (HttpCookieCollection cookies)
		{
			if (cookies == null || cookies.Count == 0)
				return;

			if (!(context.WorkerRequest is IHttpExtendedWorkerRequest))
				return;
			IHttpExtendedWorkerRequest exWorker = (IHttpExtendedWorkerRequest) context.WorkerRequest;
			bool inPortletMode = !context.IsServletRequest;
			bool shouldStoreCookiesCollection = false;
			HttpSession javaSession = exWorker.GetSession (false);

			if (javaSession == null && inPortletMode)
				javaSession = exWorker.GetSession (true);

			if (javaSession == null)
				return;

			object sessionLock = GetJavaSessionLock (javaSession);
			lock (sessionLock) {
				Hashtable sessionCookies = (Hashtable)javaSession.getAttribute (SessionCookies);			
				if (sessionCookies == null)
					if (inPortletMode) {
						sessionCookies = new Hashtable ();
						shouldStoreCookiesCollection = true;
					}
					else
						return;

				ArrayList sessionStoredCookies = null;
				for (int i=0; i < cookies.Count; i++) {
					HttpCookie cookie = cookies[i];
					if (sessionCookies [cookie.Name] != null || inPortletMode) {
						sessionCookies [cookie.Name] = cookie;
						if (sessionStoredCookies == null)
							sessionStoredCookies = new ArrayList();
						sessionStoredCookies. Add (cookie.Name);
					}
				}

				if (sessionStoredCookies != null)
					foreach (object key in sessionStoredCookies)
						cookies.Remove ((string) key);

				if (shouldStoreCookiesCollection)
					javaSession.setAttribute (SessionCookies, sessionCookies);
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:48,代码来源:HttpRequest.jvm.cs

示例6: GetSessionCookiesForPortal

		internal void GetSessionCookiesForPortal (HttpCookieCollection cookies)
		{
			if (context == null)
				return;
			if (!(context.WorkerRequest is IHttpExtendedWorkerRequest))
				return;
			IHttpExtendedWorkerRequest exWorker = (IHttpExtendedWorkerRequest) context.WorkerRequest;
			HttpSession javaSession = exWorker.GetSession (false);
			if (javaSession == null)
				return;

			object sessionLock = GetJavaSessionLock (javaSession);
			lock (sessionLock) {
				Hashtable sessionCookies = (Hashtable) javaSession.getAttribute (SessionCookies);
				if (sessionCookies == null)
					return;

				ArrayList expiredCookies = null;
				foreach (string key in sessionCookies.Keys) {
					HttpCookie sessionCookie = (HttpCookie) sessionCookies [key];
					if (sessionCookie.Expires.Ticks != 0 &&
						sessionCookie.Expires.Ticks < DateTime.Now.Ticks) {
						if (cookies [key] != null)
							cookies.Remove (key);
						else {
							if (expiredCookies == null)
								expiredCookies = new ArrayList();
							expiredCookies.Add (key);
						}
					}
					else
						cookies.Set (sessionCookie);
				}

				if (expiredCookies != null)
					foreach (object key in expiredCookies)
						sessionCookies.Remove (key);
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:39,代码来源:HttpRequest.jvm.cs

示例7: ClearSwitches

 protected void ClearSwitches(HttpCookieCollection cookies)
 {
     foreach (var key in cookies.AllKeys)
     {
         if (Regex.IsMatch(key, @"^itofs_"))
         {
             cookies.Remove(key);
         }
     }
 }
开发者ID:pseudomuto,项目名称:is-this-on,代码行数:10,代码来源:CookieStorageProvider.cs

示例8: updateCookie

 private static void updateCookie(HttpCookie cookie, HttpCookieCollection cookies)
 {
     cookies.Remove(cookie.Name);
     cookies.Add(cookie);
 }
开发者ID:hazzik,项目名称:NHibernate.Burrow,代码行数:5,代码来源:SpanStrategy.cs


注:本文中的System.Web.HttpCookieCollection.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。