IPHONE Etiketli Yazılar

C# – Mobil girişleri yönlendirme

 
private static readonly Regex MobileRegex = new Regex(@"(nokia|sonyericsson|blackberry|IPHONE|samsung|sec-|windows ce|motorola|mot-|up.b|midp-)", RegexOptions.IgnoreCase | RegexOptions.Compiled);

public bool IsMobile
{
	get
	{
		HttpRequest r = HttpContext.Current.Request;
		if (r.Browser.IsMobileDevice)
			return true;
		if (!string.IsNullOrEmpty(r.UserAgent) && MobileRegex.IsMatch(r.UserAgent))
			return true;
		return false;
	}
}

protected void Page_Load(object sender, EventArgs e)
{
	if (IsMobile) Response.RedirectPermanent("Mobile.aspx", true);
}