I am trying to test a client Windows CE / Compact Framework (.NET 3.5) app on handheld devices (Motorola/Symbol 3090 and 3190), but, although a "fake" client attaches and works fine on the desktop, the client app on the desktop fails to connect - it gets a 400 Not Found error when trying to call a RESTful Web API method.
This is with the server / Web API app running in Visual Studio, hosted by the built-in / scaled-down version of IIS.
Is this to be expected (not connecting)? If not, what might the problem be?
Note: I had to mash Ctrl+Shift+Enter after entering "cmd" in the Start > Run box (otherwise I get "The requested operation requires elevation (Run as administrator)"). But note the fingerwag I got after running the second command (copied from the command shell):
netsh http add urlacl url=http://192.76.42.42:80/ user=everyone
URL reservation successfully added
netsh firewall add portopening TCP 80 IISExpressWeb enable ALL
So since it "executed successfully" I'm fine - don't have to worry about redoing it, correct? I take it that the fingerwag is a "I know what you meant, and I took care of it for you, but next time you do this, do it this other way..." type of message.
Apparently it is doch applicationhost.config, in C:\Users\clay\Documents\IISExpress\config, not application.config in the project.
I had this there:
<site name="HandheldServer" id="20">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\HandheldServer\HandheldServer" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:28642:localhost" />
</bindings>
</site>
and changed it to this (IP Address changed):
<site name="HandheldServer" id="20">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/"
physicalPath="C:\HandheldServer\HandheldServer"/>
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:176.111.222.42" />
</bindings>
</site>
I stopped and started IIS by entering "iis" at the command line and selecting "Stop" and then "Start" in IIS Manager (I'm hoping/assuming that restarting IIS is the same thing as "restart your IIS Express" mentioned by Jeow below), but I still get "Unable to connect to the remote server" when I try to run the client app on the handheld (with the server ASP.NET Web API app running on the desktop, started from Visual Studio 2013).
Do I need to start that app elsehow than from VS? If so, how? When running it via F5 from VS, the page that opens is on port 28642.
My IIS applicationhost.config file now has this for this app:
<bindings>
<binding protocol="http" bindingInformation="*:80:176.112.111.25" />
<binding protocol="http" bindingInformation="*:28642:localhost" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>
where the first binding is my desktop IP address, the second one is the port VS uses when running this app, and the fourth one is the ssl version (not used yet, at least not deliberately).
The middle one is the one that can be seen in the browser (the "Home Page" with the ASP.NET verbiage/placeholder text).
So I'm wondering if I need to start this app externally from VS and/or need to remove one or more of these binding entries in applicationhost.config.
Silly me! I had not changed the code in the client to reference the IP address as opposed to localhost. So I changed this:
const string uri = "http://localhost:28642/api/inventoryItems";
...to this:
const string uri = "http://192.112.442.13:80/api/inventoryItems";
...in the client, but it still doesn't work (although it works differently); I now get, "The remote server returned an error: (404) Not Found."
Should I not have the "80" there, or...???
and the binding in applicationhost.config should be like so, correct:
binding protocol="http" bindingInformation="*:80:192.112.442.13"
?
I tried removing the port number (80), and still get the "404" error...
I finally got past that error, but two things were different, so I'm not sure whether it was one, the other, or perhaps a combination of both.
One) I deployed directly from VS 2008 by selecting "Windows CE Device" in the Target Device comboBox. I had been building the project and then copying the .exe to the handheld device via Windows Exploder.
The Other) I also changed the URL I was using in the code from my IP Address to my machine name, IOW from:
const string uri = "http://192.112.483.97:80/api/platypups";
...to:
const string uri = "http://DBPlatypus/api/platypups";
So...I am now connecting to the server and its RESTful method!
The entries in applicationhost.config are now:
<binding protocol="http" bindingInformation="*:PLATYPUS" />
<binding protocol="http" bindingInformation="*:28642:localhost" />
And now it's back to the 404 Not Found error. That was a short-lived "voila"! Que sera sera, I reckon...it seems to be related to a new err msg, namely, "Unable to launch the IIS Express Web server"
Okay, in applicationhost.config, I changed this:
<bindings>
<binding protocol="http" bindingInformation="*:DBPlatypus" />
<binding protocol="http" bindingInformation="*:28642:localhost" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>
to:
<bindings>
<binding protocol="http" bindingInformation="*:28642:localhost" />
<binding protocol="http" bindingInformation="*:80:192.112.184.42" />
</bindings>
...and I got IIS Express back...but why? Maybe it's true that the name (as opposed to the IP Address) was confusing IIS Express... I'm still getting the 404 Not Found error, though...
const string uri = "http://DBPlatypus:80/api/platypusBills";
const string uri = "http://DBPlatypus/api/platypusBills";
const string uri = "http://192.112.184.42:80/api/platypusBills";
const string uri = "http://192.112.184.42/api/platypusBills";
You need to configure your IIS Express to serve your application on your IP address. By default, it only respond to localhost, which your Mobile emulator/device cannot see.
Look at 1. Getting IIS Express to serve externally over Port 80 section in http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx
Quoted from the site
Run the following in command line
netsh http add urlacl url=http://hanselman-w500:80/ user=everyone
netsh firewall add portopening TCP 80 IISExpressWeb enable ALL
Add to applicationHost.config
<binding protocol="http" bindingInformation="*:80:hanselman-w500" />
Then restart your IIS Express.
Edit:
Run ipconfig in command line to get your current IP address, and replace hanselman-w500 with that IP address.