B4J Question [SOLVED]Webview not displaying Webpages from B4J server

Peter Lewis

Active Member
Licensed User
Longtime User
I have a b4j server running and with webview, In Chrome it works perfectly
If I use Webview I cannot get the local page loaded served by b4j server
If I change webview to an external identical page , it loads

I tried something very simple, with and Without http:// , tried 127.0.0.1, Local IP and even localhost

has anyone had the experience before ? How do I solve it ?

Thank you

Simple code:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI

    Private WebView1 As WebView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    WebView1.LoadUrl("127.0.0.1")
End Sub
 
Solution
Hi Peter. The WebView is not as smart as a full fledged browser be sure to add a content-type and status code to your resp in the server side, usually when you just send a resp.write is not sufficient

cklester

Well-Known Member
Licensed User
When you run the B4J server, it will tell you what IP address to use. It will also include a port number.

Try using this URL: 127.0.0.1:51042
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
I used port 80

server port:
srvr.Port = 80

Did you try using the actual IP address of the computer? Run "ipconfig" from a CMD prompt to obtain this address.

localhost and 127.0.0.1 may not work on some computers that omit these entries in the HOSTS file.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Did you try using the actual IP address of the computer? Run "ipconfig" from a CMD prompt to obtain this address.

localhost and 127.0.0.1 may not work on some computers that omit these entries in the HOSTS file.
as mentioned in my initial post
"Without http:// , tried 127.0.0.1, Local IP and even localhost"
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
I have now tested another Webserver on a different port on the same machine and still it does not display the website used. I need interaction between the webpage and the b4j server or I would just load the html page
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
If there is no solution to this, I think my next option would be to download Chromium remove all the items I do not want, compile it and set as an external document with the default browser being Chromium

I have tried to Download the source of my webpage that I want to load, It downloads fine. I put it into a file and tried to load it using webview and loadhtml. Did not work

The html contents are correct. I cannot see why Webview does not work, Even tried it from a different PC on the same network , Chrome displays it perfectly, but webview does not.


html page:
<!doctype html>
    <html lang="en">

          <head>
            <!-- Required meta tags -->
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <link rel="icon" href="assets/img/favicon.ico" type="image/ico">

            <!--Box Icons-->
            <link rel="stylesheet" href="assets/fonts/boxicons/css/boxicons.min.css">

            <!--AOS Animations-->
            <link rel="stylesheet" href="assets/vendor/node_modules/css/aos.css">

            <!--Iconsmind Icons-->
            <link rel="stylesheet" href="assets/fonts/iconsmind/iconsmind.css">

            <!--Google fonts-->
          

            <!--Master slider-->
            <link rel="stylesheet" href="assets/vendor/masterslider/style/masterslider.css">
            <link rel="stylesheet" href="assets/vendor/masterslider/skins/black-1/style.css">

            <!--Swiper slider-->
            <link rel="stylesheet" href="assets/vendor/node_modules/css/swiper-bundle.min.css">
            <!-- Main CSS -->
            <link href="assets/css/theme.min.css" rel="stylesheet">

            <title>LED Dancefloor Control</title>
          </head>
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
You should specify scheme:// in loadUrl, it is mandatory, it may be http, https, file etc. even though URL is domain you must add the scheme:// to access it

WebView1.LoadUrl("http://127.0.0.1") should work

In my pc, it works.
That is one of the things I tried as I specified in my initial question, I tried lots of options

with and Without http:// , tried 127.0.0.1, Local IP and even localhost
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi Peter. The WebView is not as smart as a full fledged browser be sure to add a content-type and status code to your resp in the server side, usually when you just send a resp.write is not sufficient
 
Upvote 0
Solution
Top