Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

NameValueCollection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 20 Apr 2008 15:30 GMT
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

Signature

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

Peter Bromberg [C# MVP] - 21 Apr 2008 01:21 GMT
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

> Hi all,
>
[quoted text clipped - 28 lines]
>
> I do get the value... abc123
David - 21 Apr 2008 11:00 GMT
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?

Signature

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

> You would probably need to override the ToString method (or provide your
> own
[quoted text clipped - 42 lines]
>>
>> I do get the value... abc123

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.