Jump to content
Xtreme .Net Talk

namespace ,class :: confuse ::: it do nothing


Recommended Posts

Posted

this is class that i using for del cookies and i want to using it again in signout but it do nothing what i miss ?

 

here is signout.cs.aspx

namespace inventory
{

public class deletecookies : System.Web.UI.Page
{
	private void Page_Load(object sender, System.EventArgs e)
	{
		DelCookies();
	}

	public void DelCookies()
	{
		Session["User"] = null;
		Session["PrintAble"] = null;
		Session["SearchAble"] = null;
		Session["Sales"] = null;
		Session["Dye"] = null;
		Session["Package"] = null;
		Session["Delivery"] = null;

		HttpCookieCollection cookieCols = Request.Cookies;
		cookieCols = Request.Cookies;

		if (Request.Cookies["cookieCols"]!=null)
		{
			for(int n=0;n<cookieCols.Count;n++)
			{
				string UID = Request.Cookies["UID"].Value;
				string PASS = Request.Cookies["PASS"].Value;
			}				
		}
		HttpCookie cookie = new HttpCookie("UID");
		cookie.Expires = DateTime.Now;
		Response.Cookies.Add(cookie);
		cookie = new HttpCookie("PASS");
		cookie.Expires = DateTime.Now;
		Response.Cookies.Add(cookie);
			
		string sScript = "";
		sScript += "<script language=javascript>";
		sScript += " window.open('index.aspx','_parent');";
		sScript += "</script>";
		Response.Write(sScript);
	}
    }
}

 

 

 

here is signout.cs.aspx

 


namespace inventory
{

public class signout : System.Web.UI.Page
{
	private void Page_Load(object sender, System.EventArgs e)
	{
		if (!Page.IsPostBack)
		{
			deletecookies mc = new deletecookies();
		}
	}

}
}

  • 2 weeks later...
Posted

so your code in "signout" looks like this ..?

 

If (!Page.IsPostBack)

{

deletecookies mc = New deletecookies();

}

 

or this ..?

 

If (!Page.IsPostBack)

{

inventory.deletecookies DelCok = New deletecookies();

DelCok.DelCookies();

}

 

I can't understand why you've created a page to do this function for you. You would be better off creating a new class and adding DelCookies as a static function that takes an HTTPRequest as a parameter, i.e.

 

(class "DelCookies.cs")

Namespace inventory

{

Public Class CDeleteCookies

{

Public Static void DelCookies(HTTPRequest objRequest)

{

etc... replace "Request.Cookies" with "objRequest"

 

(You will need to #include System.Web and possibly more into your class to be able to use the HTTPRequest class - look at the #include list in one of your web page C# files)

 

You can then call this from any class/page in your application, i.e.

 

 

Public Class signout : System.Web.UI.Page

{

Private void Page_Load(Object sender, System.EventArgs e)

{

If (!Page.IsPostBack)

{

CDeleteCookies.DelCookies(this.Request);

}

}

 

}

 

 

 

I'm really not sure what you're doing in this bit -

 

HttpCookieCollection cookieCols = Request.Cookies;

cookieCols = Request.Cookies;

 

Not sure if this is a typing error, but you don't need to assign cookieCols to Request.Cookies twice !!

 

Good luck and let me know how you get on

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...