c# - Wrong browser detection on the server side -
c# - Wrong browser detection on the server side -
i have asp.net mvc 4 application , have problem detection of browser on server side. client opera useragent "mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/38.0.2125.104 safari/537.36 opr/25.0.1614.63"
send request, on server side browser name defined "chrome" , it's wrong.
var browsername = request.browser.browser;
i want browsername
defined "opera". i've tried override creation of object request.browser
.
solution 1:
i've created "browsercaps.config" file , added xml element opera file.
<browsercaps> <use var="http_user_agent" /> ... <case match="chrome/\d+\.\d+\.\d+.\d+\ssafari/\d+\.\d+\sopr/(?'version'(?'major'\d+)(?'minor'\.\d+)\.\d+.\d+)"> browser=opera version=${version} majorversion=${major} minorversion=${minor} </case> ... </browsercaps>
it works fine don't solution because overrides capabilities of browsers , need update manually.
solution 2:
i've added file "opera.browser" folder "app_browsers":
<browsers> <browser id="opera" parentid="chrome"> <identification> <useragent match="opr/(?'version'(?'major'\d+)(\.(?'minor'\d+)?)\w*)" /> </identification> <capabilities> <capability name="browser" value="opera" /> <capability name="majorversion" value="${major}" /> <capability name="minorversion" value="${minor}" /> <capability name="type" value="opera${major}" /> <capability name="version" value="${version}" /> </capabilities> </browser> </browsers>
i sent first request opera useragent, worked out , browsername
defined "opera", sent sec request chrome useragent , browsername
still defined "opera". doing wrong?
if need identify browser capabilities only, not create error if application identifies opera browser chrome one.
opera has switched rendering engine webkit lastly year, not create difference weather serve content chrome or opera or other webkit-powered browser.
c# asp.net .net asp.net-mvc asp.net-mvc-4
Comments
Post a Comment