Powered By Blogger

Monday, December 14, 2009

Reverse String - HTTP to HTTPS - Image Type(without checking extensions)

C#

string str = TextBox1.Text.Trim();
char[] chr = str.ToCharArray();
StringBuilder sb = new StringBuilder();
for (int i =0 ; i < chr.Length; i++) { sb.Append(chr[(chr.Length-1)-i].ToString());
}
Label1.Text = sb.ToString();



Change the Current page from HTTP to HTTPS

if (!Request.IsSecureConnection)
{
//to get the current URL
UriBuilder uri = new UriBuilder(Page.Request.Url);
uri.Scheme = Uri.UriSchemeHttps;

// Redirect to https
Response.Redirect(uri.ToString());
}

Find Out the Image Type without Checking its Extension
Image imgUp = Image.FromFile(Server.MapPath("~/images/abc.jpg"));
if (imgUp.RawFormat.Equals(ImageFormat.Jpeg))
Response.Write("JPEG");
else if (imgUp.RawFormat.Equals(ImageFormat.Gif))
Response.Write("GIF");


No comments:

Post a Comment