ASP State Integration

  • Thread starter Thread starter gb
  • Start date Start date
G

gb

We are in the process of upgrading part of a large system
to .NET, whilst the majority will remain ASP. Sharing
session state information will not be a problem at the
moment as it is trivial and will be passed in using
QueryString.

More pressing is the synchronisation of session timeouts
between the two environments. Is the only way to do this
to have URL references from one environment to another.
For example on the ASP pages have an .aspx reference
somewhere, or on an ASP.NET page have a .asp reference?

How would one go about doing this? Using an img src
attribute, or a hidden IFRAME element?

Thanks,

gb
 
Hi,

At first I was just going to post that I agree with you. An image tag or an
iframe is probably the easiest way for you to update "the other guy" with
the fact that activity has occurred and the server-side session time out
needs to be extended as well as the client-side cookie expiration.

However, I don't like the idea of adding an iframe if it's not necessary.
Also, an image tag needs to point to a valid image in order to avoid the
browser showing a red X. You could accomplish this by changing the IIS
application mappings for the ASP and ASP.NET applications to map *.bmp to
the ASP and ASP.NET DLL's. However, this would map all *.bmp files to
ASP/ASP.NET which would add overhead to your other *.bmp files.

---
Side notes
* You will need to manually update the *.xyz mapping when you update the
version of ASP.NET.

* If the end user changes the browser settings to not display images, then
the approach of using an image tag will not work. Similarly, not all
browsers support iframes.

* Application mappings is how IIS knows which program should process the
requested file. HTM and image files are usually just read from disk and
sent to the browser. For ASP and ASP.NET files, IIS calls into the
respective DLL. Then the DLL runs its various processes to render the file
to the browser. That's a lot more overhead.

* To set application mappings, open Internet Services Manager, properties
for the application's folder, Directory (or Virtual Directory) tab, click
the Configuration button, Mappings tab, look at the existing entries to see
how to add a new entry.
---

Back to the main topic.
You could rename a single pixel *.bmp file to *.xyz. Then, in the ASP.NET
application & ASP application respectively, map *.xyz to ASP & ASP.NET.
Then use IIS properties for the file to add necessary headers
(Content-Type: image/bmp and Cache-Control: no-cache). I didn't try this,
but I think this would be a reasonable solution for you.

Before I thought of changing the extension to *.xyz, I first came up with a
more complex idea which I did test and it worked. I don't think it's any
better than the *.xyz idea, but here it is. At least I tried this one and
found that it worked.

The idea is to have an ASPX page (you can convert it to ASP) which uses
BinaryWrite to send a one pixel bitmap. The overhead of programmatically
reading in a file to write it out seems like a lot of overhead for this
small administrative task. So, I monitored network activity while browsing
to a white, one pixel, monochrome bitmap file. Then I hard coded the bytes
into my code. Since it still has to read the ASPX or ASP file from disk,
this won't perform any better than the *.xyz approach.

Here is my sample code.

**** ASPX page
Remove everything except the @ Page declaration line.

When you do this, you will not be able to use the View In Browser feature
of Visual Studio. You will need to manually open a browser to view this
file.

**** Code-behind
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load

Response.Buffer = True
Response.Clear()
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(#1/1/2001#)
Response.AppendHeader("Pragma", "no-Cache")
Response.ContentType = "image/bmp"

Dim b As Byte() = {66, 77, 66, 0, 0, 0, 0, 0, 0, _
0, 62, 0, 0, 0, 40, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, _
0, 1, 0, 1, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, _
255, 255, 0, 128, 0, 0, 0, 0, 6, 35, 65, 131, 71, _
17, 122, 6, 195, 124, 89, 134, 189}

Response.BinaryWrite(b)
End Sub


---
Other notes

* To avoid the need to remove the HTML from the ASPX page, you could
instead call Response.End() after BinaryWrite. However, the whole purpose
is to trigger activity by browsing something. Therefore, I don't want to
short-circuit the process.

* Since you mentioned this is a large ASP application and you are just
beginning to integrate it with or convert it to ASP.NET, I think you may
like to have more info on how to share ASP and ASP.NET session data. You
will need to remove the page breaks in these links to use them.

Download details: Code Sample: Session Sharing Between Classic ASP and
ASP.NET
http://www.microsoft.com/downloads/details.aspx?
familyid=8aa45bbc-6c0b-4dcf-b7b6-2f57e7c73587&displaylang=en

How to Share Session State Between Classic ASP and ASP.NET (ASP.NET
Technical Articles)
http://msdn.microsoft.com/library/en-us/dnaspp/html/converttoaspnet.asp


Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 
Thanks for all the info, much appreciated!

Now, if I change IIS config to use ASP/ASP.NET to stream
*.xyz bitmaps to the browser do I reference this file URL
within an img src attribute? Can use a single pixel
transparent gif for this instead of a bitmap file?

As for ASP / ASP.NET session sharing, will this be fixed
in Whidbey, or will we have to wait for a new IIS in
Longhorn's server OS?
 
Hi,

Yes, I did have it mind that the *.xyz file would be referenced in the src
attribute of an img tag. If the idea works, then the file can contain any
data whose content-type is supported by the browser.

I was just thinking about another aspect. The *.xyz file will by handled by
the StaticFileHandler httpHandler per the machine.config file. I'm not sure
if that will trigger session renewal. If it doesn't work, use an *.aspx
file with BinaryWrite. It can read in a file or you can put the data
directly into the code as I demonstrated in my previous post.

I don't know how ASP session integration will be handled in the future
products whidbey or longhorn.

I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 
Back
Top