62039

How to call your own ASP.NET MVC project preaent on same machine from xamrin webview

I am creating a <strong>Xamarin WebView</strong> for an <strong>ASP.NET MVC5</strong> Application, but when I run the emulator I faced the following: ERR_Connection Refused. Can you explain me how to call project present in same machine from Xamarin WebView?

protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); web_view = FindViewById < WebView > (Resource.Id.webview); web_view.Settings.JavaScriptEnabled = true; web_view.LoadUrl("http://localhost:53183/"); }

Answer1:

Localhost within the emulator will be the emulator itself, not your PC.

Change http://localhost:53183 to:

http://:yourpcipaddress53183

Note: Most emulators also map "10.0.2.2" and/or "10.0.3.2" as your PC's loopback adapter.

http://:10.0.2.2:53183 http://:10.0.3.2:53183

You can test it via adb:

adb shell ping 10.0.2.2

Answer2:

Assuming your localhost is running under IIS express, you need to tell your windows machine to accept connections to that site/port. Open PowerShell as administrator:

netsh http add urlacl url=http://{windows-local-ip}:53183/ user=everyone

If your machine language is not english you´ll have to change "everyone" with the corresponding translation.

Then open the file applicationhost.config that you can find on YourSolution/.vs/config/applicationhost.config and search the site node corresponding to your application:

<site name="YourApplication" id="1">...</site>

Inside, you´ll find a default <binding> node pointing to localhost. Leave it as is, but add a new one with your computer local ip:

<binding protocol="http" bindinginformation="*:53183:{local-ip}"></binding>

For instance:

<binding protocol="http" bindinginformation="*:80:192.168.0.57"></binding>

When you launch/debug your website, right click the IIS express icon. You should see something like this (localhost + your ip:port):

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/SGbAd.png" alt="enter image description here">

If you still don´t see your ip like in the picture, restart Visual Studio.

Last, you may need to open the port 53183 in your firewall. Just to make sure it isn´t the firewall blocking the connection, deactivate it and try again.

Recommend

  • Run multiple instances of nightwatch at browserstack
  • Google Maps Spiderfying Markers & Adding Listeners
  • QWebView allow pop-ups?
  • Google maps adding streetview to each infowindow
  • Swift WKWebView disable Javascript
  • Mapbox title on markers always visible
  • Why doesn't the following regex work when input through Spring
  • Attachment in Gmail using code
  • Can you measure the time it takes to load a web page in a webView in Android?
  • Application using Tabs Crashes
  • Sending POST params with Netty and why isn't DefaultHttpDataFactory not in the releases?
  • ScrollPane jumps to top when deleting nodes
  • JavaFX not finding all system fonts
  • Phonegap Android App, open links within app?
  • input type=“file” accept=“image/*” doesn't work in phone gap?
  • Why is OpenID Connect considered mobile friendly compared to SAML
  • setContentView() is not enough to switch between layouts?
  • Visual Studio 2010 debugger build correctly - compiler pdb and linker pdb not in synch?
  • How to get Eclipse Oxygen to run on Java 9
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • Launch Runnable Jar from Web Start
  • In LanguageTool, how do you create a dictionary and use it for spell checking?
  • align graphs with different xlab
  • XCode can't find symbols for a specific iOS library/framework project
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How to stop GridView from loading again when I press back button?
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • How can I use `wmic` in a Windows PE script?
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize