在asp.net中,如何替换http头以改变Accept-Encoding以改变User代理



我正在开发具有相同URL动态内容的移动、智能手机、桌面网站,我无法设置不同的用户代理。默认值为Accept Encoding is coming。我们如何替换varie:接受编码以更改:用户代理?

我试过所有这些

1.<%@OutputCache Duration="180"VaryByHeader="User Agent"%>

2.HttpContext.Current.Response.AddHeader("Vary","User Agent");

3.HttpContext.Current.Items.Add("Vary","User Agent");

4.HttpContext.Current.Response.Cache.SetVaryByCustom("用户代理");

5.HttpContext.Current.Response.Cache.VaryByHeaders.UserAgent=true;

6.HttpContext.Current.Response.Headers.Set("Vary","User Agent");

但仍在

缓存控制:public,最大年龄=180内容编码:gzip内容长度:9741内容类型:text/html;字符集=iso-8859-1日期:2013年7月23日星期二12:19:23 GMT有效期至:2013年7月23日星期二12:22:22 GMT上次修改时间:2013年7月23日星期二12:19:22 GMT服务器:Microsoft IIS/7.5可变:接受编码

我想要的是

缓存控制:public,最大年龄=180内容编码:gzip内容长度:9741内容类型:text/html;字符集=iso-8859-1日期:2013年7月23日星期二12:19:23 GMT有效期至:2013年7月23日星期二12:22:22 GMT上次修改时间:2013年7月23日星期二12:19:22 GMT服务器:Microsoft IIS/7.5Vary:用户代理

感谢

"如果只想通过HTTP标头值进行缓存,则必须将VaryByParam属性设置为"None"。"

http://msdn.microsoft.com/en-us/library/vstudio/system.web.ui.outputcachelocation%28v=vs.100%29.aspx

http://msdn.microsoft.com/en-us/library/vstudio/a6s4ks5w%28v=vs.85%29.aspx

最新更新