I've got an app that I am trying to run on my dev system under IIS Express from VS2010 that I need to use port 80 for, but I can't get it to work. I've looking up information talking about port 80 being reserved.
http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/
But even after doing that I still get an error from vs2010 that says
"Unable to launch the IIS Express Web server. Port '80' is in use."
I don't know what else to try. I've used Process Hacker to track down port 80 and it seems to be used by System running on process ID 4, which is the NT Kernel and System process. I don't know if that would prevent me from using the port though. I thought maybe that was a result of http.sys holding that port so nothing else could use it?
I did managed to get IIS Express to run on port 80 by modifying the default binding of the C:\Users\[MyUser]\Documents\IISExpress\config\applicationhost.config file, and while I can start IIS Express manually this way, VS then gets an error because a binding already exists on that port. So I change it back to 8080, create the virtual directory using the button within VS2010 (which I'm guessing is the same as entering a site binding) but I still get an error when I go to debug the application. Is there something hardcoded in VS2010 that won't let it start IIS Express on port 80?
UPDATE & FIX: Ok, so I found a few more things to check and I did resolve my problem but not completely. One post suggested making sure I did not have SQL reporting services installed as it can monitor on port 80, I used to have it installed but not anymore and was not the problem I was encountering. I did however realize that I have WebDeploy installed. It was bundled with the VS2010 SP1 bundle from the Web Platform Installer. This is fine as I do want the client tools from WebDeploy, but it also installed the agent on my system which was monitoring on port 80. I went to my list of services and stopped the Web Deploy Agent Service. Soon as I did this I can now use port 80 for IIS Express from within VS2010.
New Issue related to running on port 80 in IIS Express
However my application is an MVC3 App, and I've run into a problem because the MVC3 isn't capturing my request at all, so It's not firing my controller actions or anything like that, but a txt file in the root of my app can be reached so I know it's my site that IIS Express is serving up. Anyone have any issues running an MVC3 (I don't know if it's exclusive to MVC3 or not) in IIS Express on port 80?
Just posting my own answer for this problem so I can mark the question as answered.
Check http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/
Disable the Web Deploy Agent service if you have it installed.
in my case i solved the issue by stop "SQL Server Reporting Services"
you can find it in
control panel -> sevices
THANK YOU very much for you discovering of the 'Web Deploy Agent' service! This is something that only recently got turned on as I had all this working perfectly and just today installed the updated version of IIS Express, and ran into the exact same problem with port 80. So now that I have turned off the Web Deploy agent, my system works correctly again.
As for ASP.NET MVC3, that works great for me on port 80 and port 443. It was quite a bit of work to bind both those ports so that IIS Express was able to use them as a normal user (most of it from the link you posted above), and to install the SSL certificate we use. I manually created all the entries in my applicationhost.config file to get this working, and the appropriate sites section is below:
<sites>
<site name="PHP: A Main" id="2144116512">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\var\www\amain\www" />
<virtualDirectory path="/images" physicalPath="C:\var\www\images" />
</application>
<application path="/admin">
<virtualDirectory path="/" physicalPath="C:\var\www\amain\www\admin" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:test.amainhobbies.com" />
<binding protocol="https" bindingInformation="*:443:test.amainhobbies.com" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
Note that my site is a combined PHP and ASP.NET MVC3 site, as we are in the process of re-writing the entire thing to run on ASP.NET MVC3, so most of the site is still PHP but lots of new stuff is now running ASP.NET MVC3, and that stuff works for me.
Does your IIS Express work properly with MVC3 outside of Visual Studio, or is the MVC3 stuff just not working at all?
I didn't have the Web Deploy Agent installed but ran into this issue. You can also fix this by running this command to find out which application or service is using the port and then trace it down in Task manager.
netstat -o -n -a | findstr 0.0:80
Then open Task manager, go to Processes, click the checkbox "Show processes for all users" and then click the View menu and Go to the Columns, add the PID column.
Match the Process ID from the netstat command to the PID in task manager and you will find the service or application that's using the port.
That solution helped me.
On Windows 7 or Windows Vista, from an elevated command prompt, run the following command:
console
netsh http add urlacl url=http://localhost:80/ user=everyone
This command will allow any user's application (including your own IIS Express instances) to run using port 80 without requiring administrative privileges. To limit this access to yourself, replace "everyone" with your Windows identity.
Taken from that source -> https://learn.microsoft.com/en-us/iis/extensions/using-iis-express/handling-url-binding-failures-in-iis-express
Related
I have 2 bindings for my app configured in the applicationhost.config like this:
<bindings>
<binding protocol="http" bindingInformation="*:12692:localhost" />
<binding protocol="http" bindingInformation="*:80:127.0.0.2" />
</bindings>
As you can see there is one IP binding there, at first there is no ACL setup to allow it so I have to run the VS as admin so that the binding can be done OK (otherwise the app won't run). If I run it as admin I can see the 2 bindings configured OK (they are shown in the IIS Express window accessible from the system tray icon).
Now I want it more convenient (not requiring administrative privilege) by adding the IP (for the second binding) to the ACL by using netsh like this:
netsh http add urlacl url=http://127.0.0.2:80/ user=everyone
It reported OK, then I could try reopening the project normally (not as admin) and the app run OK (not any binding error reported) but I could see just one binding (the second binding), the first binding is not configured as expected. Now if I try running the VS as admin again, it still works fine with 2 bindings configured correctly.
So looks like it's just a problem of running VS as admin or not (the ACL configuration is not involved). How could that cause the issue?
it is not a recommended way to modify the applicationhost.config file. another thing is when you open a visual studio you can only see the one site bing in the application property. if you want to use more than two bindings with a site you could use the iis or iisexpress command:
run command prompt as administrator.
enter the iisexpress.exe folder path by running below command:
cd C:\Program Files\IIS Express
then run below command to run iisexpress site:
iisexpress /config:C:\Users\Administrator\source\repos\webformtest1\.vs\webformtest1\config\applicationhost.config /site:webformtest1(3)
in this way you can see both the binding in iis express tray:
I have a Web App written based on MVC framework. It runs really well on the localhost and default port 51290. Now I need to run it using my domain name e.g. myhostname. What I have tried is to add a line in "applicationhost.config" section:
<binding protocol="http" bindingInformation="*:80:myhostname" />
When I press Ctr+F5, I got an error msg saying port 80 is in use.
The server is IIS express.
Can someone please instruct how should I run this App using host name? Thanks.
After I run visual studio as admin, everything worked!
Win+R to open the Run dialog.and type "drivers"
now you can see "etc" folder,inside that there is a file named as "hosts".open that and change local host name to your domain name.
http://www.c-sharpcorner.com/UploadFile/8d44fb/how-to-access-the-site-using-domain-name-instead-of-localhos/
Been looking through and trying all guides i found on this topic but no luck. I am running and MVC project with HTTPS and want to access the debug site with some remote mobile devices to test out the website. I followed a guide that almost work and i think I am pretty close to getting it to work. Here are the steps I have done:
Turn off Firewall
Open projectfolder of website go to \vs\config\ and open applicationhost.config
Find your site and line that contains your mapped port like this:
-edit it to get this result:
Tried to run Visual Studio as Admin at this point, Got regular error 400: Bad Request - Invalid Hostname when trying to access site from other computer
Opened CMD as Admin and ran the following command:
netsh http add urlacl url=http://*:44363/ user=everyone
- URL reservation successfully added
-Tried to start Visual studio as admin and non admin. Gets the following error message
"Unable to launch the IIS Express Web Server.
Failed to reister URL "https://localhost:44363" for site "x" Application. Error description: Cannot create file when that file already exists"
-I then have to run cmd again and remove the url with the command:
netsh http delete urlacl url=http://*:44363/
How do i get this to work with Visual Studio 2017 ? I cant be many steps from getting it to work. I have read many guides but none of them works
Amazing how such a simple common need can be so painful to fulfill out of the box in 2017!
Anyway https://github.com/icflorescu/iisexpress-proxy worked nicely for me.
Install it with node:
npm install -g iisexpress-proxy
Then its just something like:
iisexpress-proxy 51123 to 3000
Under 2 mins to get running.
Let me share my experience with Visual Studio and IIS Express that should help you. I am not using HTTPS and my project type is Web site with WCF but you should be able to accomplish your goal.
Here are prerequisites:
IIS Express installed
Visual Studio installed
Added url reservation for public port (netsh http add url=http://*:50001/ User=Everyone) from elevated command prompt.
Added firewall inbound rule for 50001 TCP port (Control Panel-->Windows Firewall-->Advances Settings-->Inbound Rules-->New Rule...)
Now let us setup a project in VS. I am using one of predefined templates with C#. Compile it and try to run it from VS. At that moment VS is starting developer instance of IISExpress that helps your site to run.
You should be able to see IIS Express icon in Notification area. With right click you will see that your site is running and a port (we will call it VSPORT) that is assigned by VS. This port must be different than reserved port (50001).
If you managed to accomplish this without problems then you have almost everything ready for running your site without VS.
Go to your project folder
Go to .vs folder
Go to config folder
Open applicationhost.config
Locate sites/your_site section
Copy everything between your_site and /your_site
Now we need to add this info in "global" IIS Express config.
Go to IIS Express folder (something like c:\Users\USERNAME\Documents\IISExpress)
Go to config folder
Open applicationhost.config
Locate sites section.
Paste information about your site.
Change binding from
binding protocol="http" bindingInformation="*:VSPORT:localhost"
to
binding protocol="http" bindingInformation=":50001:"
Save changes
With this change you may start IISExpress.exe directly and you can continue to use VS to work on you project at the same time.
If you want to access it from other computers do it as http://YOURIP:50001/.
Do have in mind that you need to ensure that your javascript code is NOT using address and port number directly.
You can solve the problem by downloading the 'conveyor' library from extensions and update in Visual Studio.
You can access it from other devices.
Open Visual Studio
Tools > Extensions and Updates
Online > Visual Studio Marketplace
Search 'Conveyor'
Download and install this extension
When you launch the API, you can access it from other devices. This plugin creates a link from your own ip address.
Example:
https://youripadress:5000/api/values
Using the [RequireHttps] port in an ASP.NET MVC application causes a redirect to HTTPS on port 443 if the user attempts to access the application over HTTP.
However, in IIS Express, the application will probably not running on port 443. It will, instead, be running on something like port 44301.
I've found various tips for replacing RequireHttpsAttribute with an implementation that takes the alternative port number as a parameter, or reads it from Web.config.
This is clunky, because it requires configuration in more than one place.
Is there any way to do this -- programmatically -- in a generic fashion?
Without trying to pre-empt the answers, some options occur to me:
Is there any way to discover the bindings being used by the instance of IIS or IIS Express that's hosting my app?
Is there any way to read applicationHost.config for the current IIS / IIS Express host?
You can check currently used bindings (of IIS/IIS Express) by running following command
"netsh http show servicestate view=requestq"
You can find applicationhost.config file of IIS Express in %userprofile%\documents\iisexpress\config folder.
I'm new to Web API Applications. I created my very first application with only one simple Controller with only one Get() method that returns a List.
In my PC it works fine. Even after I publish the solution and access it via my IIS 7.5, the results are ok: I access
http://localhost/Application/api/Controller
and I get the answer I expect.
So I moved forward to the next step: deploying it to another server so other people in my office can access it. The server we use runs a Windows 2008 server. What I did was to simply copy the Publish folder generated by the publish command in Visual Studio 2012, and paste it in the inetpub\wwwroot folder in the server computer. Then, I accessed the IIS 7.5 that's running on the server and created a new application using the .NET 4.0 Application Pool, using the Publish folder as its physical path (exact same steps I did in my PC to publish it to my IIS).
The problem: when I try to access the application in the server machine (that's running windows 2008 server), I get the 404 error. It seems like it tries to find a physical path Application\api\Controller, insted of resolving it logically like my machine does.
I did try all the different solutions I found in the web:
I did enable all verbs in the ExtensionlessUrl-Integrated-4.0 under the mappings configuration for the Application in the IIS.
I did add the WebApiConfig.Register(GlobalConfiguration.Configuration); in my global asax.
What I noticed is that my machine has the .NET Framework 4.5 installed and the server machine only has the 4.0 framework (client and extended). But I get the same error even after compiling the application targetting the 4.0 framework.
The only MVC .dll I have in my bin directory is the System.Web.Mvc.dll... do I need any other DLL?
Thanks in advance.
Try this:
<system.webServer>
.....
<modules runAllManagedModulesForAllRequests="true" />
.....
</system.webServer>