现在客户有这样一个需求,
 www.avene.cn 是用来给电脑访问的 产品 官网,
 http://avene.wapg.cn/home/avene/?user=www 是给pc访问的 产品官网 。如果, 用手机访问 www.avene.cn ,那么自动跳转至 http://avene.wapg.cn/home/avene/?user=www 如果,用电脑访问 http://avene.wapg.cn/home/avene/?user=www ,自动跳转至 www.avene.cn  不知道描述清楚没有,请高手赐教?给点具体方案和代码。

解决方案 »

  1.   

    本帖最后由 net_lover 于 2010-09-07 17:12:18 编辑
      

  2.   


    我这边也有两个 方法 ,还没测试呢,不知道行不行            if (HttpContext.Current.Request.Headers["user-agent"] != null && HttpContext.Current.Request.Headers["user-agent"].ToLower().ToString().IndexOf("mozilla") != -1)
                {
                    HttpContext.Current.Response.Redirect("http://www.avene.cn/"); //PC            }
                else
                {
                    HttpContext.Current.Response.Redirect("http://avene.wapg.cn/home/avene/?user=www"); //Mobile  ClientTypeTesting.            }        }
            public static boolean choose(String userAgent)
            {
                if (userAgent.indexOf("Noki") > -1 ||   // Nokia phones and emulators  
                    userAgent.indexOf("Eric") > -1 || // Ericsson WAP phones and emulators  
                    userAgent.indexOf("WapI") > -1 || // Ericsson WapIDE 2.0  
                    userAgent.indexOf("MC21") > -1 || // Ericsson MC218  
                    userAgent.indexOf("AUR") > -1 || // Ericsson R320  
                    userAgent.indexOf("R380") > -1 || // Ericsson R380  
                    userAgent.indexOf("UP.B") > -1 || // UP.Browser  
                    userAgent.indexOf("WinW") > -1 || // WinWAP browser   
                    userAgent.indexOf("UPG1") > -1 || // UP.SDK 4.0  
                    userAgent.indexOf("upsi") > -1 || //another kind of UP.Browser  
                    userAgent.indexOf("QWAP") > -1 || // unknown QWAPPER browser  
                    userAgent.indexOf("Jigs") > -1 || // unknown JigSaw browser  
                    userAgent.indexOf("Java") > -1 || // unknown Java based browser  
                    userAgent.indexOf("Alca") > -1 || // unknown Alcatel-BE3 browser (UP based)  
                    userAgent.indexOf("MITS") > -1 || // unknown Mitsubishi browser  
                    userAgent.indexOf("MOT-") > -1 || // unknown browser (UP based)  
                    userAgent.indexOf("My S") > -1 ||//  unknown Ericsson devkit browser   
                    userAgent.indexOf("WAPJ") > -1 ||//Virtual WAPJAG www.wapjag.de  
                    userAgent.indexOf("fetc") > -1 ||//fetchpage.cgi Perl script from www.wapcab.de  
                    userAgent.indexOf("ALAV") > -1 || //yet another unknown UP based browser  
                    userAgent.indexOf("Wapa") > -1 || //another unknown browser (Web based "Wapalyzer")  
                    userAgent.indexOf("Oper") > -1)
                {
                    return true;
                }
                else
                {
                    return false;
                }原理和你那个类似
      

  3.   

    大家继续顶啊这边还有一百分呢 
     http://topic.csdn.net/u/20100907/16/2cdfbfb3-4ae2-490d-acda-a20d5533b50d.html 
      

  4.   

    考虑:
    1. 手机通过wap上网可能会被wap网关滤掉UA
    2. UA信息未必准确建议,只判断PC用户,其他未被归类于PC的,作为手机用户处理
      

  5.   


    我下面这个方法就是这种思路,手机的浏览器很多很杂,毕竟无法全部包含。
    判断pc的话,具体该怎么判断呢?  if (HttpContext.Current.Request.Headers["user-agent"] != null && HttpContext.Current.Request.Headers["user-agent"].ToLower().ToString().IndexOf("mozilla") != -1)
      {
      HttpContext.Current.Response.Redirect("http://www.avene.cn/"); //PC  }
      else
      {
      HttpContext.Current.Response.Redirect("http://avene.wapg.cn/home/avene/?user=www"); //Mobile ClientTypeTesting.  }
      

  6.   

    a其实若是Windows 系统的,只要UA包含"Windows"或者"Windows NT",那么久肯定是PC的
    若是非Windows系统,只能用浏览器关键字了,毕竟很多手机操作系统都是Linux内核,例如“Firefox”等等
      

  7.   


    公网的ip是一样的,这个方案刚开始就被 pass 掉了 
      

  8.   

    已经解决了。大家一起测试下
    http://avene2009.nurunci.com
      

  9.   

    拿手机访问上面的地址,会跳转到   http://avene.wapg.cn/home/avene/?user=www ,
    如果是pc ,就不会跳转
      

  10.   


    没有吧。 我只是让用户访问 http://avene2009.nurunci.com  这个地址啊。我的程序会根据 用户  用户 是使用的pc还是手机,进行相应的跳转啊,怎么叫把  “把选择权还给用户”
      

  11.   

    http://avene2009.nurunci.com/product.aspx?seriesid=qq    拿去!
    Server Error in '/' Application.
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:
      

  12.   

    http://avene2009.nurunci.com/product.aspx?seriesid=1
      

  13.   

    有个地方不知道是我浏览器的问题还是你的程序问题,在你网页的下方有三个图标地方(一个信封、一个放大镜、一个新建图标)鼠标从左往右移没的问题 但从右往左就出问题 楼主可以自己去测试下  我测试的浏览器是Firefox/3.6.9    IE6.0下我好像还没看到这个效果  鼠标移上去直接不出来!
      

  14.   


    //我的问题还没解决求助中...
     protected void Page_Load(object sender, EventArgs e)
        {
            HttpCapabilitiesBase r = (System.Web.Configuration.HttpCapabilitiesBase)Request.Browser;
            string agent = (Request.UserAgent + "").ToLower().Trim();
         
            if (r.Browser == "Mozilla")
                Response.Write("可以识别:Mozilla");
            else
                Response.Write("不识别:Mozilla");
            if (r.IsMobileDevice || r.Browser == "Unknown" || r.Browser == "Mozilla")
            {
                Response.Write("手机" + "\r\n" + r.Browser + "\r\n" + r.Type);
            }
            else
            {
                Response.Write("电脑" + "\r\n" + r.Browser + "\r\n" + r.Type);
            } 
        }
      

  15.   

     this.Context.Request.Browser.IsMobileDevice