Reputation: 4998
Is it possible to spoof / force the user agent string on the server side in .NET? Either through code or some mechanism in IIS?
I realize this is unorthodox, but it is a temporary solution to allow Window 10 workstations to use a legacy application until it's updated or replaced.
I should add that this is running in IIS 6.
IIS is version 7
Upvotes: 0
Views: 556
Reputation: 12749
You could try to use the IIS URL rewrite module to implement your requirement:
For that first, you need to install the URL rewrite module.
https://www.iis.net/downloads/microsoft/url-rewrite
Next, click the View Server Variables link from the Actions pane on the right. From here we need to add HTTP_USER_AGENT into the list of Allowed Server Variables by clicking Add in the Actions pane.
When this step is complete, click the Back to Rules button from the Actions pane then press Add Rules(s). Select Blank rule under the Inbound rules section (the first selection on the top left) and enter/choose the following values:
Name: This rule can be named anything you wish for it to be named
Match URL:
Requested URL: Matches the Pattern
Using: Regular Expressions
Pattern: .*
Conditions:
Logical grouping: Match All
Click Add Condition and then enter the following data:
Condition input: {HTTP_USER_AGENT}
Check if input string: Matches the Pattern
Pattern: .Trident/([7-9]|0[1-9]\d+).(rv:1[1-9]).
Server Variables:
Click Add and then enter the following data:
Server variable name: HTTP_USER_AGENT
Value: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)
Replace the existing value: Checked
Action Action type: None
After following these steps, press Apply in the Actions pane.
Note: you could use the your own value in condition pattern and server variable value.
Upvotes: 1