Why can't ASP.NET API be accessed via external ip? - c#

I have a Windows Server 2012 R2 instance and I wanted to deploy an ASP.NET Web API to it (I have used custom deployment method, saving the .rar file on disk). I have created the website inside IIS and everything is working great on http://localhost:8080.
When I try to access it by its external ip (http://12.34.567.899:8080) it won't respond.
Also, the default website on port 80 is fully working.
Things that I have tried
1. My port is open as I have run 'netstat -a' and port 8080 shows as 'LISTENING'
2. I have already checked bindings for IIS, they are ':8080'
Thank you in advance.

Related

Cannot access ASP.NET Core application hosted in a Windows Service

I'm trying to create a ASP.NET core app which is hosted in a Windows Service, following the official documentation.
The only difference I made is that I used Network Service account, and made Kestrel listen to port 10090, instead of the default 5000.
After publish the binaries to the server(Windows Server 2012 R2), everything works fine via local access(on the server using http://localhost:10090/), but the web cannot be accessed on other PCs. Showing
This site can’t be reached
server-1 took too long to respond.
This server also has some IIS hosted web application and they are working fine.
Does anybody knows the missing points I made? Thanks!
With help from my colleague I found that it is a programming issue.
When creating the IWebHostBuilder in Program.cs, I wrongly set the option of Kestrel (copy and paste from official documentation):
options.Listen(IPAddress.Loopback, 10090);
While one of the correct option is IPAddress.Any.

Can't consume self hosted (using console) asp .net 5 web api over LAN

Before marking it duplicate please read through.
I am using simple web hosting option from Visual Studio 2015, which hosts the default template web api over localhost:5000 port.
Please note that I am not using IIS express, a lot of questions out there are for IIS hosting.
I can consume them simply using http://localhost:5000/api/values. However when I try to consume this api from another system which is on LAN, using appropriate IP instead of localhost, it simply can't connect and shows error connecting to url.
You can try to reproduce this easily:
Create an ASP .NET 5 web api using Visual Studio 2015.
Select the "web" option inspite of "IIS Express" while running the solution. This would the ASP .NET web api using console over port 5000.
Now we can consume the web api by hitting : http://localhost:5000/api/values
However if I try to do the same from another system over LAN (changing localhost to appropriate IP), I can't connect.
Also, If I try to ping my system from another system over LAN, I get appropriate response.
Any help would be appreciated.
Edit the project.json file, find the "commands" section and edit the value of the "web" key to be as follows:
"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:5000"
This will cause Kestrel to listen on all addresses from all interfaces. You should also check the firewall settings; is 5000 blocked?

Creating a Web Server container to emulate an IIS server

Okay, I'm a very green developer (co-op student) so I'll try my best to make sense. Currently I have a web application (call it "Updater") that is an aspx and runs through IIS. My boss has asked my to look into creating a program (exe or command line) that can run the app through created encapsulated web server that can act like IIS. This is so that I can run the exe during an installer procedure on a client's machine so that the updater can configure the client's program.
So Far I've looked into sources upon sources on how to create a self hosted web server to handle a web app and I've managed to do the following:
-Create a command line server hosted at a given port #######.
-Use a StreamReader to read an html file
-Use HttpResponseMessage to set the Content to this html page.
Obviously this is very rudimentary, but I couldn't understand how to switch the app over to the server I created rather than the IIS.
Any help ont he matter would be appreciated, like I said I'm still quite new.
You can use OWIN to self host from within a console application.
Look for 'Self-Host OWIN in a Console Application' in the following link:
http://www.asp.net/aspnet/overview/owin-and-katana/getting-started-with-owin-and-katana
You need to start you self host server with the address your app is trying to contact. If your IIS is running with the default settings it should be http://localhost:80. Before you start the self host server you need to shut down your IIS website that is running on port 80. Two applications can not listen on the same port at the same time.
What you ask is a redistributable web server for ASP.NET. So, you might find interesting the UltiDev Web Server, formerly known as Cassini web server.
From their website:
UltiDev Web Server Pro (UWS) is an advanced, redistributable web server for Windows that can be use as a regular web server to host web sites and ASP.NET applications, or packaged with your ASP.NET web application and installed on your customers' systems along with your web app or site.

How to host a web service so other clients connected to same network can access

I am hosting web service in a one machine using Visual studio 2008. I tried accessing the web service from a web site i created in the same solution and it was successfully called. Now i want to access the web service from a remote client.
I initially developed the web service to used in an android application. As you can see if I wan to access the web service I will have to host is with a static IP. So at least to test the application i want access the web service from the android mobile by connecting both server and android mobile to one wifi network. For the initial test I connected two laptops(one is server) to the wifi router. And i pingd the server from the client machine and it got successfully pingd. But when i try to access the web service with given port from the browser it wont allow me to connect. I tried http://localhost:26796/ by replacing the localhost with ip of the server and also i tried making a small web site(asp) and try to access it from the client via IP. Both did not work. I have searched here and on web could not find a proper answer. for,
how to host a webservice so other clients in the same network can access..?
can it be fulfilled with VSD server..?
is it compulsory to use iis..?
How should i achieve this..?
NOTE: Moved from comments to answer as per user suggestion.
Publish the web service to your local machine's IIS as an Application. Then you can access the site from anywhere in your network. Running it directly from VS means it's hosted inside VS's ASP.NET Development Server (which, by default is only accessible locally). You can try opening up the port specified in the ASP.NET development server that starts up on your machine's local firewall, then you can access the debug instance being hosted

Silverlight socket

I downloaded the silverlight 4 socket application from the book "Pro silverlight 4 with c#" which is basically just a silverlight socket client and server application. The server is a console application and the client is a silverlight web applcation.
I can run the server and client fine on ONE computer, it shows that its connected and so on, but when i tried connecting to the server on a different computer (Local Network), it wont connect. Any idea??? Eventually i want to put this on the internet and go live, not local. When i run using visual studio development server, it shows localhost and port 1091, and i thoguth silverlight only uses port 5200 somthing.
Silverlight applications are only allowed to connect back to the site it was loaded from by default, much like Java and Flash does. If you need to communicate with another server, that server needs to explicitly allow it by running a policy service listening to port 943, or by serving a policy file over HTTP port 80. See http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx for the full details on how to implement this.
Have you added policy file to you "C:\inetpub\wwwroot"?
I used example from "Pro silverlight 3 with c#" and its work from internet and local.
I added policy file to "C:\inetpub\wwwroot", where my silverlight website was published and everything works fine.
Note that website published in the same machine where server application runs.
Hope this will help you.

Categories