How to change port number for IIS - asp.net

I am using Web Matrix 3 for practicing ASP.NET but I cant run any Web Page because of an error. When I run any page I got this message
Port '44300' is already being used by process 'IIS Express' (process ID '820').
Recommendations:
1. Try switching to port other than '44300' and higher than 1024.
2. Stop the application that is using port '44300'
I dont know how to change or swich port. Can anyone help me to solve this problem ?

This is because as it says, the port is being used already. What you should do is create the application in Sites > Default Web Site. This should let you run the application without any problems.

Related

grpc in a ASP core host: context deadline exceeded

I am trying to connect to a grpc service in a ASP Core application that is in a windows 10 computer.
I want to connect with grpui. If I run grpcui in the same computer, without TLS, I can use this way:
grpcui -plaintext localhost:5110
Then I would like to connect from another computer (a virtualbox windows 10). So I use this command:
grpcui -plaintext 192.168.1.2:5110
But I get an error that tells "context deadline exceeded".
If I disabled the firewall in the service computer, then I get another error: "No connection could be made because the target machine actively refused it.". So the problem it seems that firewall in the server computer.
NOTE: I will not pay attention to this second error, I would like to solve first the first one. Later if I need, I will open another question for that, to avoid to mix two different problems in one question.
Then I have add 2 rules in the outbunds, one for the .exe file of the asp application and another for the conhost.exe file in windows\system32. This is because in the taskmanager it seems these are the 2 files that is running when I run the ASP application. I do the same for the inbounds rules.
But the problem is the same.
So which are the rules that I have to set in the firewall to can allow to connect to the service?
Thanks.

OWIN self hosted doesn't receive connections from outside

I have a project which is made of a console application which listens to a port and acts when a message is received.
The messages are received from an asp.net web api based web site.
Both work properly together.
I wanted to combine both solutions into one executable file.
To accomplish that I used OWIN self hosted solution.
I managed to merge the web site into the console application and when working from my local machine I manage to see the web site and everything works well.
The problem occurs when I try to open the website from another machine\device connected to my LAN.
I get no response. I know it is not a firewall issue since my OWIN self hosted using the standalone website's port (I put the website down to make the port available).
This problem didn't occur when both solution where seperate.
I assume it is an owin configuration issue.
I tried to use the following code but I get access denied exception.
options.Urls.Add($"http://{Dns.GetHostName()}:{port}");
options.Urls.Add($"http://localhost:{port}");
If I use only
options.Urls.Add($"http://localhost:{port}");
There is no exception and it works from my computer as expected but not from another machine.
I did some search but didn't manage to make it work.
Any kind of assistance will be appreciated.
Thanks in advance!
you can either use specific ip-address or use * to listen on a port
I use below code for specific ip-address
var ip = Dns.GetHostEntry(Dns.GetHostName());
var ipaddress = ip.AddressList.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork);
options.Urls.Add($"http://{ipaddress}:{port}");
or you can also do
options.Urls.Add($"http://*:{port}");
Open the ports on the firewall and
instead to use it
WebApp.Start("http://localhost:8080/");
Use it:
WebApp.Start("http://*:8080/");

How to access ASP.NET app from another pc on the same network?

I'm running a ASP.NET on my pc and I would like to access to that app from another pc on the same network. I've tried to reach the app writing the URI of my pc on the network followed by the port number as below:
"192.168.X.X:49223/"
But it shows me an 400 error saying that it's an invalid hostname...
Is there something to do with my windows firewall or in IIS to allow access from another PC ?
Thanks for your help.
You may need to an exception in Windows Firewall.
Control Panel > Windows Firewall > Advanced Settings > Inbound/Outbound rules.
Add a new rule to both, specifying your port number and a generic name to identify its purpose.
Install IIS server on your machine, then deploy your application on that IIS server.
Refer this for Deployment assistance
To run the application on IIS instead of ASP.Net dev server you need to
Right click on solution in VS
Click on Start Options..
In Server section, Select "Use Custom Server" and then provide the URL of the application you have added earlier on IIS
Then you can easily access your website from any other machine on the same network.
Is it hosted in iis, or are you running it through Visual Studio. The funny port number (49223) tells me it's the latter.
When you run a VS project, the dev server is designd to only allow local conconnections. If you connect from a network it gets blocked by design. Their is no config around it.
What I do as a hack is run a reverse proxy like Nginx. It's a free download. Run it on your dev machine. You can tell it to listen on a port (eg 88) and then redirect tge traffic to port 49223. Give your mate the same url as before but replace the port with 88
Nb make sure your port 88 is open as per codemans answer
An example of the nginx config would be https://gist.github.com/ekinertac/5524389
This then tricks VS into thinking it came from your local machine.

The request failed with HTTP status 400: Bad Request ( The data is invalid. ): Code base Works on one machine but not another

This will probably be an environmental issue but I'm stumped as where to start.
I'm attempting to call a a webservice on an external server in an asp.net web app while debugging in VS2008. The exact same code/project works on one machine calling the server but on another machine (my new one) it fails with the 400 Bad request (data is invalid) error.
Both machines are running Windows 7. What should I be looking for as differences in the two machines that could be contributing to this problem?
Edit Deleting the webreference in the project and re-creating the webreference had no effect
Update
I went to use Fidler2 to inpect the request and response which resulted in the error going away. Things are beginning to point to an internet proxy issue.
It's an Internet Proxy issue. The suspect machine had be configured to manually use a proxy server. Turning this off: Control Panel -> Internet Options -> Connections Tab -> Lan Settings Button, and enabling "Automatically detect settings" has fixed the problem.

Is there any issue with using the same AppPool for two sites that use different ports on the same machine?

I have two ASP.NET 4.0 test sites on a Windows 2008 server (IIS7) One uses port 80 the other port 5050. I set the same AppPool for both. The second site(the new one on port 5050) is having problems finding the SQL box on the network. Could the shared AppPool be a problem?
BTW I didn't choose this setup. I'm just trying to make it work.
Could the shared AppPool be a problem?
Very unlikely. Ports and IPs are configured per site, not per AppPool.
The second site(the new one on port 5050) is having problems finding
the SQL box on the network.
Are you using the same connection strings from both apps?
No definitely not. Because when you try to connect, Your application is client for SQL server. make sure SQLServer default instance port 1433 is not blocked if you are using different instance of server for second App.
That mean if your first application is happy then second App should connect without any problem irrespective of you ASP.Net app port number
this is just basic knowledge, If you post any Exception Details Would be great.

Resources