Hi,
In this article a few useful Extension Methods for HttpResponse.
We often need to Write something to Response with New Line at the End or Switch Current Response to Ssl Mode.
Instread of using :
Response.Write("Something<br/>");
Response.WriteLine
public static void WriteLine(this HttpResponse response, Char o)
{
response.Write(String.Concat(o, "<br/>"));
}
public static void WriteLine(this HttpResponse response, String o)
{
response.Write(String.Concat(o, "<br/>"));
}
public static void WriteLine(this HttpResponse response, Object o)
{
response.Write(String.Concat(o.ToString(), "<br/>"));
}
Response.SwitchToSsl
public static void SwitchToSsl(this HttpResponse response)
{
String baseUrl = HttpContext.Current.Request.Url.OriginalString;
Uri uri = new Uri(baseUrl);
String url = baseUrl.Replace(uri.Scheme, Uri.UriSchemeHttps);
response.Redirect(url, true);
}
Hope this help’s.
Views(1922)

