System.Web.HttpServerUtility.UrlEncode C# (CSharp) Method

UrlEncode() public method

public UrlEncode ( string s ) : string
s string
return string
		public string UrlEncode (string s)
		{
			HttpResponse response = context.Response;
			if (response != null)
				return HttpUtility.UrlEncode (s, response.ContentEncoding);
			else
				return HttpUtility.UrlEncode (s);
		}

Same methods

HttpServerUtility::UrlEncode ( string s, TextWriter output ) : void

Usage Example

 public static void OutputExcel(System.Web.HttpServerUtility server, System.Web.HttpResponse response, string filename, MemoryStream ms)
 {
     byte[] bytes = ms.GetBuffer();
     response.Charset         = "UTF8";
     response.ContentEncoding = Encoding.UTF8;
     response.AddHeader("Content-Disposition",
                        "attachment; filename=" + server.UrlEncode(filename + ".xls"));
     response.ContentType = "application/vnd.ms-excel";
     response.BinaryWrite(bytes);
     response.End();
 }
All Usage Examples Of System.Web.HttpServerUtility::UrlEncode