Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6082307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:16:29+00:00 2026-05-23T11:16:29+00:00

I need a class to manipulate URLs in asp.net WebForms eg Url url =

  • 0

I need a class to manipulate URLs in asp.net WebForms

eg

Url url = new Url("http://www.stackoverflow.com");

if(!url.Params.Contains("user"))
  url.Params.Add("user", "1");

I have tried NameValueCollections but they seem to be readonly as do a number of objects in HttpContext

NameValueCollection nv = Request.QueryString;

nv.Remove("ForeignLanguage");
nv.Add("ForeignLanguage", l.ID.ToString());

The above generates a Collection is readonly exception

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:16:30+00:00Added an answer on May 23, 2026 at 11:16 am

    I would use the UriBuilder class, in conjunction with the very handy HttpUtility.ParseQueryString method:

    var uri = new UriBuilder("http://www.stackoverflow.com");
    NameValueCollection parameters = HttpUtility.ParseQueryString(string.Empty);
    parameters.Add("user", "1");
    uri.Query = parameters.ToString();
    return uri.ToString();
    

    Note the trick with passing an empty string to the ParseQueryString method – this will give you a (writable) instance of System.Web.HttpValueCollection, a non-public class that derives from NameValueCollection and (among other things) emits its contents in querystring format when you call its ToString method.

    You could also manipulate the current url:

    var uri = new UriBuilder(Request.Url);
    NameValueCollection parameters = HttpUtility.ParseQueryString(uri.Query);
    // TODO Manipulate parameters...
    uri.Query = parameters.ToString();
    return uri.ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to manipulate the attributes of a label element inside an ASP.NET CheckBoxList
I am using Linq to sql concept to manipulate my data from asp.net mvc
I need a class that works like this: >>> a=Foo() >>> b=Foo() >>> c=Foo()
I need B class to have a min priority queue of AToTime objects. AToTime
Possible Duplicate: Why XML-Serializable class need a parameterless constructor Does anyone know if it
I have a class derived from Dictionary. I need this class to simulate a
Using C#, I need a class called User that has a username, password, active
I'm writing an app for Java ME, and I need a class for holding
I need a CSVParser class file A Class File which parses csv and returns
I need a Java class to submit tickets to BMC Remedy's Helpdesk product. Wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.