在aspx页面中访问GetVaryByCustomString的返回值 [英] Accessing the return value of GetVaryByCustomString in aspx page

查看:87
本文介绍了在aspx页面中访问GetVaryByCustomString的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在Global.asax中创建了以下代码:



- -------------------------------------------------- ---

  string  val1 =  ; 

public 覆盖 string GetVaryByCustomString(HttpContext context, string custom)
{
if ( custom == browser
{
val1 = context.Request。 Browser.Browser + + context.Request.Browser.MajorVersion;
// return context.Request.Browser.Browser ++ context.Request.Browser.MajorVersion;
}
else
{
val1 = base .GetVaryByCustomString(context,custom);
// return base.GetVaryByCustomString(context,custom);
}
return val1;
}





---------------------- --------------------------------



现在我想在我的网页上显示此返回值(val1)。我没有找到任何方法。请帮帮我。



谢谢&关于



IB

解决方案

创建服务实例并使用该调用在这里调用meethod ..

  public   partial   class 默认值:System.Web.UI.Page 
{
Service1 srvc = new Service1() ;

受保护 void Page_Load(对象发​​件人,EventArgs e)
{

}

受保护 void Button1_Click( object sender,EventArgs e)
{
Response.Write(srvc.GetVaryByCustomString ( )的ToString()); // 传递参数
}


}


Hi,

I have created the following code in Global.asax as:

------------------------------------------------------

string val1 = "";

        public override string GetVaryByCustomString(HttpContext context, string custom)
        {
            if (custom == "browser")
            {
                val1 = context.Request.Browser.Browser + "  " + context.Request.Browser.MajorVersion;
                //return context.Request.Browser.Browser + "  " + context.Request.Browser.MajorVersion;
            }
            else
            {
                val1 = base.GetVaryByCustomString(context, custom);
                //return base.GetVaryByCustomString(context, custom);
            }
            return val1;
        }



------------------------------------------------------

Now I want to display this return value (val1) on my web page. I am not finding any method to it. Please help me.

Thanks & regard

IB

解决方案

create the instance of the service and using that call the meethod here..

public partial class Default : System.Web.UI.Page
    {
        Service1 srvc = new Service1();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
           Response.Write(srvc.GetVaryByCustomString("","").ToString());  // pass the parameters
        }


    }


这篇关于在aspx页面中访问GetVaryByCustomString的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆