Server:
[Ajax.AjaxMethod()]
public string brow()
{

string strR="";
strR="平台为:"+Request.Browser.Platform;
return strR;
} client:
function ajx()
{
var resp=ajax.brow();
alert(resp.value);
}
</script>
但总是提示null,如果将return strR改为return "las"则可以显示为las,为什么呢?用response对象也是一样,但用其他对象则不会!

解决方案 »

  1.   

    改称试试:
    public string brow()
    {
    try
                                {
    string strR="";
    strR="平台为:"+Request.Browser.Platform;
    return strR;
                                }
                                catch(Exception err)
                                { return err.Tostring()}
    }
      

  2.   

    System.Web.HttpException: 请求在此上下文中不可用 at System.Web.UI.Page.get_Request() at aspobj.ajax.brow() in e:\csharp\aspobj\ajax.aspx.cs:line 41