Retrieve browser data server-side from Javascript in Linux Environment

0
1

Hi,

Meanwhile, I would like to thank all the Wisej staff for the excellent framework you provide, which allows even non-professionals like me to develop on Web.

I would like to read at Application startup the value of the browser being used.

I have tried three different ways, all of which work in development Environment on Windows, while in release on Linux Ubuntu only the last one works, but it is a trick and does not seem robust to me

Public BrowserInfo As String

  1. Application.Eval(“navigator.userAgent”, Sub(response)

BrowserInfo = CStr(response)

End Sub)

2.  Private Async Sub RequestBrowserInfo()

Dim response As String = CStr((Await Application.CallAsync(“getBrowserInfo”)))

BrowserInfo = response

End Sub

 

3.  Javascript module:

window.addEventListener(“mousemove”, submitBrowserStartupActions, false);

function submitBrowserStartupActions() {

window.removeEventListener(“mousemove”, submitBrowserStartupActions, false)

App.GetBrowserStartupProps(navigator.userAgent);

}

Program.vb module:

<WebMethod>

Public Sub GetBrowserStartupProps(browserInfo As String)

BrowserInfo = browserInfo

End Sub

 

It is not clear to me why, since the data in the third case is also available on Linux, in the other cases it does not arrive server-side. Do you have any suggestions?

Thanks,

Antonio

 

Update

I found a solution for browser recognition using Application.UserAgent which is perfect and I noticed that I have to collect the data at the opening of the page instead of in the Main of Program, but this is not a problem. However, I also need active browser zoom, which I should get from Javascript:

Math.round(window.devicePixelRatio * 100);

If I collect the data from Javascript it is not stored in the variable. Maybe because a delay is needed? I also tried displaying it via a button in a label shortly after the page opens, but while the one read from Application.UserAgent is displayed, the one generated by Javascript does not arrive. This always happens only on the server-published version, while in Visual Studio I see both.

  • You must to post comments
0
0

Hi Alaa,
Awesome, I hadn’t seen that at all.
Application.Browser.PixelRatio is what I needed.

Thank you very much!
Best regards,

Antonio

  • You must to post comments
0
0

Hi Antonio,

Did you by any chance take a look at the Application.Browser property?

If not, you can always take a look at our Documentation!

From what it looks like, it has all the things you might need without having to fiddle with JavaScript!

HTH,
Alaa

  • You must to post comments
0
0

Here it is!

I placed the 4 different tests all in one button click event.

Thanks; best regards.

Antonio

  • You must to post comments
0
0

Hi Antonio,

can you please wrap up a small compilable sample showing how you call your javascript code?

Best regards
Frank

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.