473,246 Members | 1,410 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,246 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 2091
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.