Last post Apr 21, 2018 10:15 AM by anooshiravan
Member
243 Points
156 Posts
Apr 21, 2018 07:29 AM|anooshiravan|LINK
I have a third party web user control and it seems that it only generates some javascript code if it detects some specific browser(e.g IE 11)
so how can I fake it so the user control thinks it is IE 11 not chrome or firefox?
Contributor
4873 Points
4125 Posts
Apr 21, 2018 08:27 AM|DA924|LINK
https://jsfiddle.net/311aLtkz/
You check to see if it's IE and then do something.
Apr 21, 2018 10:15 AM|anooshiravan|LINK
I found that using a class that inherits IHTTPMODULE and then adding an event handler for Begin_Request() I can change the user agent.
public class UserAgentHandler : IHttpModule { public void Init(HttpApplication app) { app.BeginRequest += new EventHandler(BeginReq); } public void Dispose() { } public void BeginReq(object sender,EventArgs e) { NameValueCollection headers = HttpContext.Current.Request.Headers; headers.Remove("User-Agent"); headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"); } }
Member
243 Points
156 Posts
browser detection
Apr 21, 2018 07:29 AM|anooshiravan|LINK
I have a third party web user control and it seems that it only generates some javascript code if it detects some specific browser(e.g IE 11)
so how can I fake it so the user control thinks it is IE 11 not chrome or firefox?
Contributor
4873 Points
4125 Posts
Re: browser detection
Apr 21, 2018 08:27 AM|DA924|LINK
https://jsfiddle.net/311aLtkz/
You check to see if it's IE and then do something.
Member
243 Points
156 Posts
Re: browser detection
Apr 21, 2018 10:15 AM|anooshiravan|LINK
I found that using a class that inherits IHTTPMODULE and then adding an event handler for Begin_Request() I can change the user agent.