User1024191908 posted
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");
}
}