안녕하세요 이것은 내 작업 필터입니다. 적절한 동작으로 리디렉션 할 화면 크기를 감지해야합니다. 어떻게 할 수 있습니까 ??asp.net MVC4 : 필터에서 화면 너비를 감지하는 방법 동작?
public sealed class DetectViewFilterAttribute : ActionFilterAttribute
{
private readonly IRegistrationConfiguration _registrationConfiguration;
public DetectViewFilterAttribute()
{
_registrationConfiguration = DependencyResolver.Current.GetService<IRegistrationConfiguration>();
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
bool isMobile = false;
string userAgent = HttpContext.Current.Request.UserAgent.ToLower();
Regex mobileDetectionRegularExpression = new Regex(_registrationConfiguration.DetectMobileRegularExpression);
isMobile = mobileDetectionRegularExpression.IsMatch(userAgent);
if (isMobile)
{
String url;
UrlHelper helper = new UrlHelper(filterContext.RequestContext);
// TODO **if width de device between 300 and 600 px*
url = helper.Action("Mobile","Inscription");
else
url = helper.Action("Tablette","Inscription");
HttpContext.Current.Response.Redirect(url);
}
base.OnActionExecuting(filterContext);
}
} 슬프게도
마케팅 서비스 here 모바일 및했던 Tablette에 대한 두 개의 서로 다른보기를 만들기 위해 부탁드립니다. 장치에서 클라이언트 측 브라우저 너비를 감지해야합니다. – user1428798