Manage localhost ports when developing with Visual Studio with several users on one machine - asp.net

In our Visual Studio development (VS2015), we share one virtualized machine with several developers. We had to solve several minor problems with this setup but discovered a more annoying problem now.
Our solution consists of a client that uses web services, that are implemented in a ASP.NET project. When we start our client, we also start the services so that the calls can be made from the client. The services get started on the localhost port that is entered in the project properties. But when we work with several developers we have the problem that Visual Studio would use the same port for all developers and as we are on the same machine, the web project will not start because the port is already used. We now have following questions:
We can separate the ports by editing the IIS config file but we also have to change the port in the client and after each checkin all developers again have the same port.
1) Is there a clever way to manage the ports in the local IIS express?
2) How can we configure the ports in the clients so that the configuration is not overwritten by each checkin of other developers?

Related

Reference web projects from other web projects in solution

I am working in Visual Studio 2013/2015. I have three web projects in my solution. I want these web projects to be able to make calls to each other, which means that they need to know at what port they are hosted on during development.
I am hosting in IIS Express, which by default means that they get auto-assigned ports. This is good because if a port is unavailable, another port will be used. Since the port is determined at runtime I cannot have a configuration file in each projects which says where the other projects are hosted.
Other than manually assigning ports, is it possible to somehow reference these other web projects from one web project and then make calls where the used port is substituted?

Want to run my own server instance with special port for an ASP.Net 4 based solution

I have made an application in asp.net which sends and receive sms, it works very similar to desktop application and it will be installed on servers to send sms alerts, but the problem is if server does not have iis, it will not work. I have seen many apps which when installed, have their own server and port, you do not need to install any IIS, when you just double click it starts running on a special port and works well, similarly visual studio also runs its own port in development mod, so what is the best way to make such solution for an asp.net product.
If you're talking about how to host a service in an application outside IIS, Windows Communication Foundation (WCF), which allows you to host a service in a Windows Forms executable, Console Application, Windows service, or IIS.
It's too big a subject to explain fully here, but there's a nice starting point here.
This will allow you to create the host, and allow you to hose services similar to web services, but with more options for how to connect. (http, tcp, etc.)
But it's not an ASP.NET host. For that, you will need a web server that can execute ASP.NET, such as IIS. There's no way to get around the need to have a web server, whether it's one of the many already established, or if you write your own. I believe there are extensions for Apache that allow you to do so via Mono, but I've never used them. Writing your own would be, in my opinion, a waste of time and a bad idea.
The simplest solution by far is to specify that IIS instaled with the appropriate framework is a requirement for using your website.
Edit
However, if you REALY want to write a WinForms app and have it host ASP.NET, it looks like this previous question has an answer that would help. You can use the Cassini web server, the same one that Visual Studio uses.

How to run a leightweight ASP.NET MVC application that would be accessible only locally (not on IIS)?

We have a desktop client application and recent customer requests indicate that they would like to have some dynamic HTML content served and displayed by the application.
We are considering hosting a simple ASP.NET application in a local process, accessible only from the local machine (similar to the ASP.NET development web server used when debugging from Visual Studio).
How can we run an ASP.NET application locally without IIS? IIS is not an option because most client machines will not have it installed.
Is there a leightweight ASP.NET web server that could run locally similar to the development web server that VS is using?
I have found some information about "Cassini". Is this suitable for production use? Can it handle ASP.NET MVC? Are there any alternatives we should consider?
I have not used it myself, but you can try the mono XPS server.
It is a stand alone webserver.
The easiest way to start XSP is to run it from within the root directory of your application. It will serve requests on port 8080. Place additional assemblies in the bin directory.
Cassini is in fact also a good option - it is the development web server that comes with visual studio (so widely distributed, used and tested) and is also used by the open source ScrewTurnWiki. See wikipedia.
In regards to your "only locally" requirement - a web server will serve any request made to the right port. In order to limit accessibility, you should use a firewall that will block any external requests.
You might consider using WCF to host a service on the local machine that can serve the data without having to host a full blown web server.
If you do this, WCF allows you to expose the service with multiple endpoints and make it available through HTTP, TCP, or Namepipes. Namepipes would restrict traffic to only the local machine.
I have also tried IIS Express. It works great with ASP.NET MVC. Right now it is available only with Web Matrix, but installing web matrix is easy.
Coming back to this question three years later, ServiceStack.NET with self-hosted option seems like a good choice. While it is not ASP.NET MVC directly, it provides a good API and features are on par with ASP.NET MVC/WebAPI (or in some ways better).

Viewing ASP.net Development Server from virtual machine

Microsoft recommends testing older versions of IE with the following virtual machines
This is all fine and good, except that the virtual machines can't see the Dev Server from Visual Studio. This makes it very difficult to develop or debug since I have to copy or deploy to IIS for every little change I make. I've tried using ARR, but it seems it can only forward to one specific port at a time, whereas i need to have the port typed in the address bar of the virtual machine to match the port that it is connecting to on the host machine. Is this possible?
You shouldn't need to deploy to IIS to test changes.
We set our IIS up on development machines to point to the web project folder.
Once IIS is setup, you can add an existing website to your solution, select Local IIS and select the Site from the list of sites (rather than browsing the file system and selecting a .csproj file). You'll now have your site in VS that is hosted by IIS, ready to change and debug, and accessible from remote machines.
Generally speaking you cannot access the ASP.NET Development Server on one machine from another.
Here's some additonal notes on what you cannot do with ASP.NET Development Server from MSDN
ASP.NET Development Server is specifically built to serve, or run, ASP.NET Web pages under the local host scenario (browsing from the same computer as the Web server). In other words, the ASP.NET Development Server will serve pages to browser requests on the local computer. It will not serve pages to another computer. Additionally, it will not serve files that are outside of the application scope. The ASP.NET Development Server provides an efficient way to test pages locally before you publish the pages to a production server running IIS.
The ASP.NET Development Server works only with individual pages and does not include the extra facilities of IIS. For example, the ASP.NET Development Server does not support an SMTP mail server. If your Web application involves sending e-mail messages, you must have access to the IIS SMPT virtual server to test e-mail because the ASP.NET Development Server cannot forward e-mail messages or invoke a server that does.
Anyway.....
Googling around I have found an article where somebody had success on accessing a Development Server remotely using a reverse proxy. I have not tried but here's the link
Configuring a Basic Reverse Proxy in Squid on Windows (Website Accelerator)
Also have a look at this StackOverflow question that has answers describing varous methods to achieve your results
Is There a Way to Make Remote Calls to ASP.NET Development Web Server?
You need to type the development server port into the address bar of the client browser, otherwise host the application in IIS and use the default port.
It is overkill to test with this number of configurations in the development environment. It is generally sufficient to test with 2 or 3 configurations while you are writing code (say IE8, FireFox) - just run these from the local machine (no need for a virtual machine). Once you've finished the UI, deploy your application to a test environment running IIS and test it against the larger range of configurations.
If you test each small change against all of these configurations as the change is made, you'll find yourself overwhelmed with testing. Don't forget that as well as the MS recommended test environments, various configurations of other browsers and operating systems (such as FireFox and Opera, Mac OS) are equally important - you may choose to only test a subset of these configurations depending on your resources.
I too found the link Lorenzo mentions in his comment, but had no luck with Squid configuration.
Happily there's a much easier method, as noted here.
Go to CNET and download SPI Port Forwarder
(Note: Click the "Direct Download Link" below the big green "Download Now" button. If you use the Download Now button CNET tries to install adware on your machine before giving you the file. It's very odd.)
In the first column, "Local Port" put the port you want people to connect to your machine on. I wanted people to come in on 80.
Second column, "Remote host", put "localhost" (it'll apparently port-forward to other machines).
Third column, "Remote port", put the port of the local webserver (in my case the ASP.NET Development Server on port 2485).
Click "Activate"
Hope this helps.
I am answering this old question to help peoples who wants to make it work without IIS. Thank you Fiddler !
1. First Step
You have to download Fiddler.
Once Fiddler is downloaded and installed, open it.
Go in Tools-> Fiddler Option-> Connection tab-> And check "Allow remote computers to connect" :
Restart Fiddler.
2. Second Step
After this, in the VM, open internet explorer-> Internet Options-> Connection Tab-> Lan Settings-> Check "Use a proxy server for your LAN" :
The adress is the IP adress of your DEV machine.
And put the port 8888
Now, you can access the ASP.NET Web Server from your VM !
To access it -> http://localhost.:54814
Don't forget the additional point after "localhost" !
The port, "54814" in my case, is the ASP.NET Web Server port.

How do I setup WebDeploy on Windows 2003 / IIS6?

Webdeploy is an alternative to WebDav, FTP, and FrontPage extensions. It also acts as an alternative to DFS for replicating websites. I found instructions for configuring Windows 2008, but I'm unclear how to set up 2003 especially when multiple sites / IP Addresses are present.
It is possible to install Web Deploy Tool 1.1 on Windows 2003 for IIS6. Generally this tool is used for synchronization between remote/local sources. You can refer to the following article about how to use Web Deploy Tool 1.1 on Windows Server 2003:
Synchronize IIS 6.0 Web Sites
http://learn.iis.net/page.aspx/445/synchronize-iis-60-web-sites/
However, it's not possible to use this tool to enable publishing from Visual Studio 2010 to the webserver. The reason is that this method relies on ‘Web Management Service’, which is newly introduced in IIS 7. This service can be used when there are some users delegated to manage certain sites or applications on the server. However, this service does not exist on Windows Server 2003.
IIS Web Management Service (WMSvc):
http://technet.microsoft.com/en-us/library/cc735010(WS.10).aspx
I use WebDeploy (MSDeploy) on 2003 servers to ensure content, IP addresses, certificates, etc remain the same across a MS NLB cluster. I also created a batch file to automate most of the different functions based on what I want to do (Full Server replication, single website, content only). Here are my notes on using the tool that I posted on my company's internal blog:
MSDeploy (http://www.iis.net/download/webdeploy) is a tool developed by Microsoft to make migrating, deploying, copying, and backing up websites easier. It was developed for IIS 7, but most features work in IIS 6. It can also be used to move a website from IIS 6 to 7 although I have not tested this. Some things to keep in mind when using MSDeploy are:
MSDeploy must be installed on both source and destination servers
The “Web Deployment Agent Service” must be running on both source and destination servers
Application Pools for the website must be created on the destination server before using MSDeploy or it will fail. I think this is fixed in IIS 7, but I am not 100% sure
When deploying a website, MSDeploy will attempt to put the files in exactly the same path on the destination server. If the path doesn’t exist on the destination server (like if the source path is D:\website and the destination server doesn’t have a D: drive it will fail)
The migrated website will have the exact same configuration as it did on the source IIS server. Some settings you might want to change after the move/copy are the website IP address and home directory path. You will need to make those changes manually on the destination server.
The metabase keys will need to be edited on a per-server basis since they are unique for each server (unless you created the sites using MSDeploy, then it uses the same key string across servers). As more and more sites get deployed with MSDeploy, the key strings will become universal for all servers since the metabase keys will be the same on all servers.

Resources