views:

443

answers:

4

We have the following code that is returning a value of "3" although no value is passed as a query string. Is there some way that the "id" is getting stuck in the server memory (since it is not user specific) or is "id" a special value. Any ideas?

if (Page.Request.QueryString["id"] != null)
{
Page.Trace.Write("Query String Key Found");
ListItemID = HttpContext.Current.Request.QueryString["id"];
}

This is in a SharePoint 2007 webpart.

A: 

If the webpart is on page that was navigated to by clicking a list item from the previous page; you'd be seeing the id of that list item.

Gurdas Nijor
A: 

There probably is a post (or GET) with parameters somewhere, that's hidden from you. Querystrings are the GET variables that are past along and there is no "stuck" or "server memory".

Use a tool like HTTPAnalyzer or Fiddler to analyze the HTTP traffic. That will show you who's making what requests. Although it's probably the ID of the control you're clicking on since you're in Sharepoint.

Mircea Grelus
When I clear all my cache, and open a new browser and navigate to the aspx page the querystring have a value even though I am specifically putting the URL in by hand.
PapaDaniel
Where does the code reside? Is it in the main page? Or is it in a control that's referenced from the page? If it's in a control that's referenced from the page do a "View Source" on your HTML and see the URL to your component. There has to be an "id" parameter in that URL.
Mircea Grelus
A: 

Clear the browser cache.

IrishChieftain
The browser cache has nothing to do with the HttpRequest
Mircea Grelus
@Mircea, I know that. But a full browser cache can cause all kinds of voodoo, especially when working on Web Parts in SharePoint.
IrishChieftain
A: 

Usually, when a webpart gets added, all parameters that it has available for input get assigned a default value, for instance, add a dataformwebpart to an ampty page and bind it to a list. Then open the source of the page. You see a bunch of parameterbindings there, which in turn can be bound to querystrings. Could you if your webpart got assigned a default value for ListItemId?

Or are you actually debugging and stepping into this particular piece of code and the id querystring variable actually contains 3? If so, I agree with one of the other answers, use Fiddler to check how many http calls are made when you open the page.

Colin