|
Hi Guru's
I'm having problem on writing cookie, not on the code but I can't seem to find the actual cookie file that was created, I also tried to placed the cookie path to my project folder but I still can't seem to find the cookie that was created. Below is my code for creating cookie.
Am I doing something wrong?
Please advice
<br />
Dim bcap As HttpBrowserCapabilities<br />
Dim bookmarkCookie As HttpCookie<br />
bcap = Request.Browser<br />
<br />
<br />
If Not bcap.Cookies = True Then<br />
wc_header.setError("Cannot bookmark page, Cookie is not enabled in this browser")<br />
Return False<br />
<br />
Else<br />
bookmarkCookie = New HttpCookie("pageBookmark")<br />
bookmarkCookie.Path = Server.MapPath("../")<br />
bookmarkCookie("pageID" & pID) = CType(pID, String)<br />
bookmarkCookie.Expires = Now.AddDays(1)<br />
Request.Cookies.Add(bookmarkCookie)<br />
<br />
Return True<br />
<br />
End If<br />
<br />
|
|
|
|
|
Cookies are saved in special folders on users computes and you cannot change this (well, you can if you change the registry settings on every machine for the cookies folder). The usual folder in which cookies are saved is [WINdrive]:\Documents and Settings\[user name]\Cookies
Cheers,
Mircea
"Pay people peanuts and you get monkeys" - David Ogilvy
|
|
|
|
|
Thanks Mircea,
I tried looking on the path you suggested but there seems to be no cookie folder, I also tried viewing hidden folders but still no luck, I don't know if its on the code although writing cookie is pretty straight forward.
Dom
|
|
|
|
|
Yes, adding a cookie is straightforward. You just have to add it to the request.
I noticed you are setting the Path property to your cookie. The path describes the url to which the cookie applies. The best thing to do is set the cookie from a page in the root folder and remove the Path property from your code.
Cheers,
Mircea
"Pay people peanuts and you get monkeys" - David Ogilvy
|
|
|
|
|
Hmm the path points to where the cookie will be created
bookmarkCookie.Path = Server.MapPath("../")
I replaced it to more a specific location but nada.. no cookie
bookmarkCookie.Path = Server.MapPath("../_cookies")
What do you mean by Set the cookie from a page in the root folder are you suggesting that I should place the page that writes cookie to the root?
Please advice
Dom
|
|
|
|
|
firestoper wrote: Hmm the path points to where the cookie will be created
NO.
The Path property indicates the path for which the cookie will be created. (path in your website structure)
firestoper wrote: What do you mean by Set the cookie from a page in the root folder are you suggesting that I should place the page that writes cookie to the root?
Either place the page in teh root or place the code that creates the cookie in a page from the root.
And remove the Path property from your code.
Cheers,
Mircea
"Pay people peanuts and you get monkeys" - David Ogilvy
|
|
|
|
|
I just place the page where calls the writing of cookie file, also I removed the path location, but no cookies was generation on the root folder. Does the page needed to be on a live webserver to generation cookies? or does this run on local web instance?
huhu..
Dom
|
|
|
|
|
firestoper wrote: Does the page needed to be on a live webserver to generation cookies?
No. Cookies are generated on localhost as well.
firestoper wrote: I just place the page where calls the writing of cookie file, also I removed the path location, but no cookies was generation on the root folder.
You just don't get it. Cookies are generated in SPECIAL FOLDERS according to the type of browser you use. Not in your website. The browser that you use decides where it stores them.
Use this tool[^] to find the path where the cookie is generated if you use Internet Explorer as the browser.
Cheers,
Mircea
"Pay people peanuts and you get monkeys" - David Ogilvy
|
|
|
|
|
Thank you for the help Mircea,
I've been using firefox sorry for that, I downloaded the app that you've gave and run the cookie page on IE browser. I checked on my cookie folder (that was shown on special folder location app) but can't find the cookie I created. To make sure I run a cookie checking script to see if there was a cookie generated, but it skipped the condition which means no cookie was created, below is my code:
pageBookmarkcookie = Request.Cookies("pageBookmark")<br />
If pageBookmarkcookie IsNot Nothing Then<br />
<br />
For x As Integer = 0 To pageBookmarkcookie.Values.Count - 1<br />
Response.Write(pageBookmarkcookie.Values(x))<br />
<br />
Next<br />
else<br />
response.write("no cookie found")<br />
<br />
End If
regards
Dom
|
|
|
|
|
I have a Session variables which i want to expose in a WebService.
Web Application:
Session["myObject"];
WebService:
[WebMethod(EnableSession = true) ]
public SuperSession GetSuperSession(string UserName)
{
List<object> ListOfObject = (List<object>)Session["myObject"];
return ListOfObject;
}
When I do this, i get the following error:
To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. System.Web.SessionState.HttpSessionState does not implement Add(System.Object).
I have tried serializing the Global object with noluck.
Any ideas?
Thanks in advance!
|
|
|
|
|
I feel that, you won't be able to share session created by webapplication in webservice. Instead of doing this, why don't you pass your serializable class object to webservice method directly ?
|
|
|
|
|
Hi,
I made a windows software for one of my client and the windows software used to do long task in background thread, Now he wants me to implement the same thing as ASP.NET Web application. I am afraid if it is really possible in ASP.NET to implement background worker thread as I know ASP.NET request has limited time allowance and after that time, the request is killed. Would you please let me know any idea.
Regards
|
|
|
|
|
You can set the Script.Timeout value to some arbitrarily high number at the start - just warn them that they must not navigate away or close their browsser until it is finished. (They can always open another tab if they want...)
And/or you can experiment with this
http://www.xmlx.net/software/2005/08/anatomy_of_a_pr.html[^]
to give them something to look at while it's happening...
|
|
|
|
|
hi Smith,
Thanks a lot for the article. This will help.
Regards.
|
|
|
|
|
Can't you implement it as a service that runs on the server?
Cheers,
Mircea
"Pay people peanuts and you get monkeys" - David Ogilvy
|
|
|
|
|
I'm at a loss for ideas- I have a relatively complex application that uses data retreived from Active Directory (compared against an SQL table) to determine user rights. For the administrative web backend, I need a way to search for Active Directory users (by name) from an ASP.NET form. I haven't got a darned clue how to do this, since I'm relatively new to AD integration with web applications.
Can someone help me, or at least point me in the right direction?
|
|
|
|
|
You can use LDAP with DirectorySearcher to find a particular user in AD. You have a lot of articles Link 1[^], Link 2[^], Link 3[^]
|
|
|
|
|
I've just started dabbling in ASP.NET properly and might be missing something obvious here, in this snippet of code:
<asp:Panel ID="panRepresentatives" runat="server" Visible="<%#this.GetDefaultVisible() %>">
<h1>Executive Committee Discipline Representatives</h1>
<asp:Repeater ID="repRepresentatives" runat="server" DataSourceID="dsRepresentatives">
<HeaderTemplate>...</HeaderTemplate>
<ItemTemplate>...</ItemTemplate>
<FooterTemplate>...</FooterTemplate>
</asp:Repeater>
</asp:Panel> What should happen is the panel should not be rendered when there are certain query strings passed to the page. GetDefaultVisible is implemented as such:
protected bool GetDefaultVisible()
{
if ((this.Request.QueryString["position"] == null) && (this.Request.QueryString["id"] == null))
return true;
return false;
} Now above this in the page is another asp:Panel which is always displayed, but inside that is another asp:Repeater control and the visiblity of this is controlled by another method which matches the database Position against the position passed in the query string or the database Id against the query string id . If they match then that particular panel is displayed, otherwise it's hidden.
The hiding / showing of panels is working fine in the code above this snippet but for the provided snippet the call to GetDefaultVisible is not happening at all , by stepping through the code I've verified that GetDefaultVisible is not called from the Visible="..." section of panRepresentatives .
Can anybody see what is wrong? I can provide more code if required but it's tied up in database connectivity and it's not really relevant to the discussion.
|
|
|
|
|
Is there a reason you wouldn't want to do this in the Page_Load event?
protected void Page_Load(object sender, EventArgs e)
{
if ((this.Request.QueryString["position"] == null) && (this.Request.QueryString["id"] == null))
panRepresentatives.Visible = false;
else
panRepresentatives.Visible = true;
}
|
|
|
|
|
I could, perhaps it's just a personal preference but the GetDefaultVisible is actually used by another part of the page (the omitted) part. But I'll try putting a call to it in there and see if anything changes. If it does all well and good but it still doesn't get away from the fact that it should be getting called, even if there is a better way of writing the page .
|
|
|
|
|
You could still do
panRepresentatives.Visible = GetDefaultVisible(); I think the problem is with the Page life cycle of an Asp.Net page. I probably need to sit and think what happens in the page life cycle for the panel. I just had my lunch and really lazy to do it
|
|
|
|
|
That's what I just did, anyway thanks for the help, but I've decided I've approached things the wrong way (generally, in terms of planning for the future). So I'm going to have a sit down and a doodle while watching House and design it properly
|
|
|
|
|
[update]That does work as expected[/update]
I'll use that method for now, but it still doesn't explain why the method isn't called, oddly enough if you copy the Visible="<%#this.GetDefaultVisible() %> " attribute through all the children of the panel then the panel is hidden, but that kind of defeats the purpose of it.
|
|
|
|
|
Hi,
I need a tree control inside a grid control, i.e.., every node of the tree should be a row in the grid control.
I want to implemented this using AJAX. Please let me know how this has to be implemented.
|
|
|
|
|
Why do u want to use tree control in gridview?
U can also implement this without tree control
Best Regard
Pathan
---------------------------------------------------
|
|
|
|