Last post Dec 16, 2006 06:50 PM by jshepler
Dec 14, 2006 05:11 PM|jshepler|LINK
I'm trying to figure out how I can have multiple browser windows that share the same session to uniquely identity which window they're coming from. I have a billing/support ticket system that I'm working on that stores the current customer object in the
session. If an employee is working on one customer in a window and they press CTL-N to open a new window to look at another customer, the session is overwritten because the two windows share the same session.
It can't be something page-based as there are multiple pages.
It has to be something that is available to server-side code on the page's first hit (IsPostBack == false).
Through testing, I've found that when a new window is opened from a window, it doesn't inherit that window's name. So, I can check if the current window's name is blank, then set it some unique string (guid or DateTime.Now.Ticks). I can then use the window's
name as a prefix or suffix on the session keys (ie. Session["CurrentCustomer" + windowname]).
If not window.name, what else can I use to uniquely identity which browser window a request came from?
Dec 14, 2006 08:44 PM|jshepler|LINK
I'm investigating the possibility of creating a browser helper object to add the current window's name to the http request headers. I found a nice writeup about how to do BHOs in .net (http://weblogs.asp.net/stevencohn/articles/60948.aspx)
and I found, I think, a list of events I can subscribe to (http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reference/objects/internetexplorer.asp).
Being an intranet application, I can code directly for IE - I don't have to worry about supporting other browsers.
However, looking at the properties/methods, nothing jumps out as a way to 1) access the window name or 2) add a custom http request header.
Anyone familiar with writing BHOs that can help me out?
Or, any other suggestions on how to accomplish what I'm trying to do?
Dec 16, 2006 06:50 PM|jshepler|LINK
Ok, I got a BHO coded up and I'm subscribing to the BeforeNavigate2 event. I figured out how to grab the window's name (SHDocVw.WebBrowser.Document.parentWindow.name). One of the parameters passed is some kind of structure representing additional headers
that will be sent in the reqeust. I can't figure out how to add anything to this structure.
[in] Pointer to a VARIANT structure of type VT_BSTR that contains additional HTTP headers to send to the server (HTTPURLs only). The headers can specify things such as the action required of the server, the type of data being passed to the server,
or a status code.
Does anyone know how I'm supposed to use this?