473,404 Members | 2,137 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,404 software developers and data experts.

NameValueCollection

Hi all,

I am developing a CMS with URL Rewriting. This however hides my valid
Request.QueryString values, which returns the underlying one that is used by
the ReWriting.

However, I have a plan... I am putting the string (which I can easily get
to) into HttpContext.Current.Item["MyQueryString"] which I then return
later. This sort of works, but I want to be able to use it like the
querystring...

So, if I then put it into a NameValueCollection like QueryString is, then I
want to be able to get at it like you would do with Request.QueryString.

My QueryString is within my Page class (My regular pages inherit from my
Page Class). So, I return it as something like...

string MyVal = Page.QueryString

However, this returns System.Collections.Specialized.NameValueCollection

If I was to do MyVal = Request.QueryString, I get the list of querystring
collection rather than the type.

How can I get it to return my collection?
notes...
If I put ?dave=abc123 in my querystring, then when I do...

string MyVal = Page.QueryString["dave"];

I do get the value... abc123
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
Jun 27 '08 #1
2 1481
You would probably need to override the ToString method (or provide your own
method) of the NVC to concatenate the names and values appropriately and
return the resultant "querystring", e.g. ?name=value&name2=value2 etc.
--Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net
"David" wrote:
Hi all,

I am developing a CMS with URL Rewriting. This however hides my valid
Request.QueryString values, which returns the underlying one that is used by
the ReWriting.

However, I have a plan... I am putting the string (which I can easily get
to) into HttpContext.Current.Item["MyQueryString"] which I then return
later. This sort of works, but I want to be able to use it like the
querystring...

So, if I then put it into a NameValueCollection like QueryString is, then I
want to be able to get at it like you would do with Request.QueryString.

My QueryString is within my Page class (My regular pages inherit from my
Page Class). So, I return it as something like...

string MyVal = Page.QueryString

However, this returns System.Collections.Specialized.NameValueCollection

If I was to do MyVal = Request.QueryString, I get the list of querystring
collection rather than the type.

How can I get it to return my collection?
notes...
If I put ?dave=abc123 in my querystring, then when I do...

string MyVal = Page.QueryString["dave"];

I do get the value... abc123
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
Jun 27 '08 #2
Thanks... I will look into it.

I am not sure where to start... would it be something along the lines of...

Create a new class that inherits from NameValueCollection

then the ToString() is overridden
something like...

public class MyNVC : NameValueCollection
{
protected override string ToString()
{
return MyConcatenatedString;
}
}
Would I then be able to just do Page.QueryString and it will automagically
return the complete string?

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Peter Bromberg [C# MVP]" <pb*******@yahoo.NoSpamMaam.comwrote in message
news:6B**********************************@microsof t.com...
You would probably need to override the ToString method (or provide your
own
method) of the NVC to concatenate the names and values appropriately and
return the resultant "querystring", e.g. ?name=value&name2=value2 etc.
--Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net
"David" wrote:
>Hi all,

I am developing a CMS with URL Rewriting. This however hides my valid
Request.QueryString values, which returns the underlying one that is used
by
the ReWriting.

However, I have a plan... I am putting the string (which I can easily get
to) into HttpContext.Current.Item["MyQueryString"] which I then return
later. This sort of works, but I want to be able to use it like the
querystring...

So, if I then put it into a NameValueCollection like QueryString is, then
I
want to be able to get at it like you would do with Request.QueryString.

My QueryString is within my Page class (My regular pages inherit from my
Page Class). So, I return it as something like...

string MyVal = Page.QueryString

However, this returns System.Collections.Specialized.NameValueCollection

If I was to do MyVal = Request.QueryString, I get the list of querystring
collection rather than the type.

How can I get it to return my collection?
notes...
If I put ?dave=abc123 in my querystring, then when I do...

string MyVal = Page.QueryString["dave"];

I do get the value... abc123
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

Jun 27 '08 #3

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

Similar topics

3
by: Walter Zydhek | last post by:
I am having a problem using the NameValueCollection type. If I remove one of the items while iterating through an collection of this type, I end up with an exception. This exception is:...
5
by: anon | last post by:
I need a little clarity in the NameValueCollection. Within the MSDN .NET 1.1 Framework help is says: "This collection is based on the NameObjectCollectionBase class. However, unlike the...
0
by: Nicole_new C# Programmer | last post by:
I am creating an application where I have 3 listboxes. The 1st holds the attributes of our products like division, group, etc. The 2nd listbox holds the values attach to each attribute like...
7
by: davidw | last post by:
I always use NameValueCollection. But I read an article says the only differece between Hashtable and NameValueCollection is that NameValueCollection could accept more than one value with same key?...
0
by: Vikram404 | last post by:
Hi, I am getting the following exception from a NameValueCollection. I dont understand the situation in which this exception can occur and I am not able to create it in Debug mode. The...
4
by: Steve Long | last post by:
Can anybody help me out with a code sample or other info on how to implement SyncRoot on a NameValueCollection? Or, is there another .NET class that does this for me with the same functionality as...
0
by: Yuri Vanzine | last post by:
Saw this requested awhile ago on Matthew Reynolds's blog here: http://www.dotnet247.com/247reference/msgs/11/57944.aspx Problem: often times I deal with querystring-formatted strings w/o the...
3
by: Mike Logan | last post by:
We are trying to serialize the Request.ServerVariables collection (NameValueCollection) to an XML formatted string, to insert into a database. The problem we are running into is that most of the...
4
by: Kerr | last post by:
Hi all, I've been scouring the internet for help with this problem and every occurance i've seen reconstructs the problem but no one seems to have a solution. Hoping that you guys can help me. ...
2
by: MrDotNet | last post by:
Hi I want pass NameValueCollection as parameter in webmethod. I try it but that give me error. Here is Error. You must implement the Add(System.String) method on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.