473,320 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Munging URLs to store data

Hello. I'm a reasonably new ASP.NET programmer
with no prior ASP or web development experience,
but a lot of general programming experience. I'm
using Visual Web Developer Beta Express 2005.

I'm trying to find a way to store data in the
URL of my pages. I know that SessionState does
this if you go cookieless, and that's useful but
it's not what I want because the real data is
stored on the server, and only an ID code is
stored in the URL.

What I'm doing is implementing a database search
that displays results in a manner similar to
Google, such that 32 results will be displayed on
four pages, with 10 results per page. Of course,
there's only one actual "search results" page and
the virtual page the user is on is stored in a
variable, Session("ResultsPage"). When the user
presses the LinkButton to take them to the next
page of results, what actually happens is that the
variable is incremented by one, the same page is
reposted and the Page_Load function fills an
HttpPlaceholder Control with the next set of
results.

Now, this all works excelently... until you take
into account the browser's back button. When the
user has gone from the Search page to Results Page 1,
then Results Page 2, pressing Back should take them
back to Results Page 1, but of course it doesn't,
since 1 and 2 are really the same page reposted
differently due to data in a cookie.

Since a browser's history is based on URLs, you
clearly want to store the ResultsPage variable in
the URL itself, so that Back works properly. If you
look at the URLs Google uses when you search, you
can see that it does exactly this.

So anyway, my question is how you achieve this
URL-mangling in ASP.NET. I've read through every
description of the HttpSessionState class that I
can find, and I can't find any referance to URL-
variables in a non-cookieless session.

If someone could tell me where in the Framework
this functionality could be found, I'd greatly
appreuciate it. I just need the procedure calls
and class names that are used; I can learn the
rest easily myself.

Thanks for your time and interest,

-- Julian Mensch

Nov 19 '05 #1
2 2094
It sounds like you're looking for the QueryString collection (accessible
through the Request object). The QueryString collection contains all of the
name/value pairs contained after the '?' in a given URI. For the URI:
http://www.somesite.com/SearchResults.aspx?pageNumber=1
pageNumber=1 is the QueryString.

I obviously don't know the specifics of your solution but one way to
implement using a querystring is to use a Hyperlink control and set the
NavigateUrl property to SearchResults.aspx?pageNumber=1 or
SearchResults.aspx?pageNumber=2, etc...

To retrieve the value from the QueryString, just use:
[C#]
int pageNumber = Int32.Parse(Request.QueryString["pageNumber"]);

[VB - sorry if this is syntactically incorrect, I usually use C#]
Dim pageNumber as integer =
Int32.Parse(Request.QueryString.Item("pageNumber") )

In either case, when reading the value, you should first make sure that it
exists in the collection (It's not null/nothing).

HTH
----------------
Dave Fancher
http://www.davefancher.com

<jm*****@shaw.ca> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hello. I'm a reasonably new ASP.NET programmer
with no prior ASP or web development experience,
but a lot of general programming experience. I'm
using Visual Web Developer Beta Express 2005.

I'm trying to find a way to store data in the
URL of my pages. I know that SessionState does
this if you go cookieless, and that's useful but
it's not what I want because the real data is
stored on the server, and only an ID code is
stored in the URL.

What I'm doing is implementing a database search
that displays results in a manner similar to
Google, such that 32 results will be displayed on
four pages, with 10 results per page. Of course,
there's only one actual "search results" page and
the virtual page the user is on is stored in a
variable, Session("ResultsPage"). When the user
presses the LinkButton to take them to the next
page of results, what actually happens is that the
variable is incremented by one, the same page is
reposted and the Page_Load function fills an
HttpPlaceholder Control with the next set of
results.

Now, this all works excelently... until you take
into account the browser's back button. When the
user has gone from the Search page to Results Page 1,
then Results Page 2, pressing Back should take them
back to Results Page 1, but of course it doesn't,
since 1 and 2 are really the same page reposted
differently due to data in a cookie.

Since a browser's history is based on URLs, you
clearly want to store the ResultsPage variable in
the URL itself, so that Back works properly. If you
look at the URLs Google uses when you search, you
can see that it does exactly this.

So anyway, my question is how you achieve this
URL-mangling in ASP.NET. I've read through every
description of the HttpSessionState class that I
can find, and I can't find any referance to URL-
variables in a non-cookieless session.

If someone could tell me where in the Framework
this functionality could be found, I'd greatly
appreuciate it. I just need the procedure calls
and class names that are used; I can learn the
rest easily myself.

Thanks for your time and interest,

-- Julian Mensch

Nov 19 '05 #2
Yes, this is exactly what I needed. The
Framework is very large, and sometimes it
just becomes difficult to find the right
calls.

Thank you graciously for your help.

-- Julian

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: phpkid | last post by:
Howdy I've been given conflicting answers about search engines picking up urls like: http://mysite.com/index.php?var1=1&var2=2&var3=3 Do search engines pick up these urls? I've been considering...
11
by: Haines Brown | last post by:
I have e-mail addresses in HTML source files both as commented information information and also as part of an e-mail link. Naturally, I'd like to hide them from harvesters to discourage more spam....
18
by: Ralf W. Grosse-Kunstleve | last post by:
My initial proposal (http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't exactly get a warm welcome... And Now for Something Completely Different: class autoinit(object):...
1
by: jlynker | last post by:
Can href= value be filled in by a datafld variable? After reviewing the link object, data islands and anchors array, there's something missing here. I would like to keep an XML file of URLs and...
7
by: AES | last post by:
Encountered a URL containing a comma the other day -- the first time I've ever noticed that, so far as I can recall. It worked fine, however, and I gather commas are legal in URLs. Out of...
5
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I...
3
by: Tony A. | last post by:
Quick question - would I be right in saying that urls in for example css content or background-image elements cannot be a javascript: or data: type urls? Doesn't seem to work in Firefox 1.5, just...
10
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're...
0
by: LinkMemory | last post by:
It is the innovative way of keeping all your Favorite URLs on the web. http://www.linkmemory.com You come across many new websites each day. You forget it as soon as you close your browser. It...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.