Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » Samples » Downloads
Add your own
alternative version

UrlBuilder Part II - Encoded QueryStrings

, 29 Sep 2005
Taking UrlBuilder to the next level.
using System;
using System.Text;

namespace CraigLabs.Web.Code {
	public class Base64 {
		public static string Encode(string value) {
			try {
				byte[] bytes = new byte[value.Length];
				bytes = Encoding.UTF8.GetBytes(value);

				return Convert.ToBase64String(bytes);
			} catch(Exception e) {
				throw e;

		public static string Decode(string value) {
			try {
				Decoder decoder = new UTF8Encoding().GetDecoder();

				byte[] bytes = Convert.FromBase64String(value);
				int charCount = decoder.GetCharCount(bytes, 0, bytes.Length);

				char[] chars = new char[charCount];
				decoder.GetChars(bytes, 0, bytes.Length, chars, 0);

				return new String(chars);
			} catch(Exception e) {
				throw e;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United Kingdom United Kingdom
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 29 Sep 2005
Article Copyright 2005 by lotuspro
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid