NameValueCollection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David

    NameValueCollection

    Hi all,

    I am developing a CMS with URL Rewriting. This however hides my valid
    Request.QuerySt ring 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.Cur rent.Item["MyQueryStr ing"] 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 NameValueCollec tion like QueryString is, then I
    want to be able to get at it like you would do with Request.QuerySt ring.

    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.QueryStrin g

    However, this returns System.Collecti ons.Specialized .NameValueColle ction

    If I was to do MyVal = Request.QuerySt ring, 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.QueryStrin g["dave"];

    I do get the value... abc123


    --
    Best regards,
    Dave Colliver.

    ~~
    http://www.FOCUSPortals.com - Local franchises available


  • =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=

    #2
    RE: NameValueCollec tion

    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 "querystrin g", e.g. ?name=value&nam e2=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




    "David" wrote:
    Hi all,
    >
    I am developing a CMS with URL Rewriting. This however hides my valid
    Request.QuerySt ring 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.Cur rent.Item["MyQueryStr ing"] 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 NameValueCollec tion like QueryString is, then I
    want to be able to get at it like you would do with Request.QuerySt ring.
    >
    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.QueryStrin g
    >
    However, this returns System.Collecti ons.Specialized .NameValueColle ction
    >
    If I was to do MyVal = Request.QuerySt ring, 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.QueryStrin g["dave"];
    >
    I do get the value... abc123
    >
    >
    --
    Best regards,
    Dave Colliver.

    ~~
    http://www.FOCUSPortals.com - Local franchises available
    >
    >
    >

    Comment

    • David

      #3
      Re: NameValueCollec tion

      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 NameValueCollec tion

      then the ToString() is overridden


      something like...

      public class MyNVC : NameValueCollec tion
      {
      protected override string ToString()
      {
      return MyConcatenatedS tring;
      }
      }


      Would I then be able to just do Page.QueryStrin g and it will automagically
      return the complete string?

      --
      Best regards,
      Dave Colliver.

      ~~
      http://www.FOCUSPortals.com - Local franchises available


      "Peter Bromberg [C# MVP]" <pbromberg@yaho o.NoSpamMaam.co mwrote in message
      news:6B26B001-5813-4256-A163-F0E77C82047E@mi crosoft.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 "querystrin g", e.g. ?name=value&nam e2=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


      >
      >
      "David" wrote:
      >
      >Hi all,
      >>
      >I am developing a CMS with URL Rewriting. This however hides my valid
      >Request.QueryS tring 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.Cur rent.Item["MyQueryStr ing"] 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 NameValueCollec tion like QueryString is, then
      >I
      >want to be able to get at it like you would do with Request.QuerySt ring.
      >>
      >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.QueryStrin g
      >>
      >However, this returns System.Collecti ons.Specialized .NameValueColle ction
      >>
      >If I was to do MyVal = Request.QuerySt ring, 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.QueryStrin g["dave"];
      >>
      >I do get the value... abc123
      >>
      >>
      >--
      >Best regards,
      >Dave Colliver.
      >http://www.AshfieldFOCUS.com
      >~~
      >http://www.FOCUSPortals.com - Local franchises available
      >>
      >>
      >>

      Comment

      Working...