Click here to Skip to main content
12,549,345 members (46,479 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET

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;
                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

Posted 1-Dec-12 0:11am
Updated 1-Dec-12 0:14am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

Indrojeet_Bhattacharya 1-Dec-12 6:30am
I am already passing the parameter as:
<%@ OutputCache Duration="30" VaryByParam="none" VaryByCustom="browser" %>

What I want is to fetch the return values of the method from Global.asax file.

Thanks & regard
Krunal Rohit 1-Dec-12 6:33am
You're not getting my solution.. I don't know your parameters.. Answer is there..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 1 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100