How to deploy a single solution with multiple projects? - asp.net

I have developed a well-decoupled website using WebAPI and AngularJS as follows:
SOLUTION
|—— WEB.API Project
|—— Website pages Project
'—— Other projects related to functionalities
This setup is on my own computer.
Now I'm here wanting to deploy to my web server (iis 7.5, privately owned, WebDeploy installed). It is possible to deploy both projects on a single web site? (other projects are class libraries, so no hassle)
For what I know, I have to deploy the WebAPI part to a website, and the UI part to another website. May I put them on a single website?

You can put the Web API project in a virtual directory under the main web site. That's what we are actually doing in our current project.

You can, but you should be worried when files conflict. If both projects have a web.config for example, this could break either of them.
If not, it should be possible, but I wouldn't immediately recommend it. I would split them off in separate virtual directories so you can maintain the two separate projects easily.

You could also self-host the Web API using OWIN, so you wouldn't then need to set up a project in IIS etc and you could then have multiple clients talking to the same API.
There's a tutorial here which is more advanced.

I have a near identical project setup. Personally I picked 2 separate apps, I have a multi server setup with load balancers - the choice may have been different if I had a single server or low amount of expected traffic.
This gives the advantage:
I expected my WebAPI to have a larger amount of traffic than the web pages, due to mobile clients also consuming the WebAPI as well as the front end webpages. Because the API is in its own website, it has its own app pool - this means that each application has its own resource pool (app can grow to use more memory and CPU better), not shared like they would be on a virtual directory.
Disadvantages:
Because there is two separate app pools, I have one bound to port 80 and the other to port 8080. As I had a large server farm to roll this out on, I already had a load balancer in front of the webservers - hence to make the URL pretty (i.e. drop the port 8080 from the URL) i added a load balancer config to allow traffic to come in on a given url on port 80 and be redirected to port 8080 on the internal webservers. This isn't really a issue if you don't mind ports in your URL's.

Related

IIS 8 publish ASP.NET core application - file in use

Is it possible to publish an ASP.NET (core) application to a running site on IIS 8 without having to stop and start the website manually?
Visual Studio 2015 keeps giving the error that a file is in use. I'm using publish to the file system, because my Web Deploy to a server in our network fails at the end with an error that it cannot authenticate on the server with port 443.
I don't mind IIS having to recycle the application pool, but when I constantly have to put the app down, publish (which takes about a minute) and restart it, it's not really good for the users.
Another option would be something like 2 websites running the same application, but only if this is automatable. Then it would put down 1 of the 2, update this, put it on, put down the second, update this and start it.
A third option is something like a hot update, where I could just update the application while it being on.
Can anyone point me in the right direction (perhaps some blog posts), because my Google searches didn't give me any good information?
If you copy a file called app_offline.htm to the application folder IIS will gracefully stop your application and start serving the contents of the app_offline.htm file. When application is stopped you can copy your files. After files are copied remove the app_offline.htm file and IIS will start your app. VS does that for you when you deploy to Azure but not when deploying to file system.
You mention "two websites running the same application". Do you mean two web servers hosting the same app?
If you already have multiple web servers (a.k.a. cluster of servers, or web farm), you can simply take some servers out of the cluster and update them. That is how we push out our updates. We use software from Citrix for managing the server farm. It also handles load balancing. This type of software allows one to monitor the servers, so you can determine when all the users have "moved" off the web servers (that were recently taken out of cluster). Then you can iisreset, deploy the new build, and move on to the next server (or set of servers, depending on your configuration). We have more than 20 virtual web servers. Typically we take down half of the servers, update them, and take the other half down as we put the first half back in the cluster/farm. This should allow for uninterrupted service. I understand you want to automate the process. I'll assume you're using Windows NLB (network load balancing). You could write a PowerShell script to automate taking down the servers. Here's a reference:
https://technet.microsoft.com/en-us/library/ee817138
I understand this may be viewed as a workaround. I'm not sure if recycling the app pool is always necessary with ASP.NET Core. I wasn't able to find a definitive answer. Most production applications should be on more than one web server anyway. Even if you don't have a lot of users, you should have multiple web servers for failover purposes.

IIS Multi-Site using same code base

I setup a Kentico CMS to host multiple sites and I'd like to know if it would be a good practice to setup multiple website in IIS using the same code base? I'm using IIS 8 on Windows 2012 R2
Chel,
I don't think having multiple IIS applications point to a single codebase is a good idea. Kentico will add/update/delete several files within your application folder as part of it's normal processing. Having multiple IIS applications performing this action on the same folder on the file system will introduce complications and errors due to file permissions and access rights.
You could set up your solution a few ways, depending on how you wanted to manage your applications.
Single IIS application / Host Headers
In this scenario, you would have a single IIS application / folder. All sites would be delivered from the same codebase. All traffic would be redirected to the same IP. In your IIS configuration, you would use host headers for each URL you wanted to send to your site. In Kentico, you would have a license / domain alias for each site you wanted to server.
PROS
This set up would give you a single codebase to manage your applications. This can simplify a good bit of your maintenance and hot fixing.
CONS
If you have to restart any of your sites for any reason, all of your sites will go down at once.
Separate codebase / IIS application for each site
In this setup, you would replicate your codebase for each site you wanted to deliver. You would create an IIS application for each codebase, configured for the appropriate URL. Each domain would be directed to the appropriate IIS application.
PROS
Can isolate your application. Can provide the ability to use different .NET frameworks / configurations for each app.
CONS
Several codebases to maintain. Updates to all sites require duplication of code across all codebases.
Personally, I would recommend option 1 if all of your sites are on the same .NET framework and it is not critical if they have to be restarted. If any of them are critical LOB applications, you may consider branching that one application off to it's own IIS application pool / codebase.

Excluding a particular IIS website from the web farm environment

We have developed a website that uses In-Proc sessions, stores images uploaded from it on a folder inside its own virtual directory, and uses a third party tool that uses server side caching. This setup works just fine in a single server instance.
But the client has a web farm environment. When we deployed this site on client's web farm. Things started failing. Till now -
we have enabled out-proc session, using SQL state management server
we specified a machine key in the web.config of the server
But the other two, specially the third party tool, is proving difficult to crack.
Will it be possible to remove this one website from the web farm? excuse me if the question sounds naive but I am not a server administrator and not aware of its nitty-gritties
Will it work if we just deactivate one of the websites?
Can we deploy this website on one of the servers in the farm, but keep it outside the web farm's load balancing?
Is there any alternative, other than deploying the website on a completely different server?
Not sure on what vendor the balanacers are but the network admin should be able to setup a VIP (Virtual IP) that translates only to the once server in question.
That is a simple answer but there are many other variables in the network architecture that would have to be answered to accomplish this. I suggest you contact the administrator of the load balancers and ask them if you can isolate traffic for the website to the specified server.

IIS, EC2, Web Farm, Web Deploy and ELB

I'm a developer now developing my startup. I really don't know much about IIS setup. I will host my startup on Amazon EC2. And I want to know how can I scale my application if my traffic increase. I been reading about MS Deploy and Web Farm Framework here: https://serverfault.com/questions/127409/iis-configuration-synchronization-for-web-server-farm . And I want a simple architecture, with not to much configuration. So I been looking an experience with an IIS web farm and Amazon ELBs. And I did not find any one.
So the question is:
It is possible to make a IIS web farm with Amazon ELBs?
Any experience on Ec2? IIS web deploy or WFF and/or without ELBs?
What you recommend for an easy web farm setup?
You can do almost anything you want with IIS on EC2. They are full servers (well window 2k8 datacenter edition) and you can open any ports you need to communicate between servers. Here is an explicit tutorial on how to set up WFF, for example, on EC2.
The question is, are you sure you need to build a web farm? If you simply want to have multiple servers running your code then you can accomplish this without anything more than IIS and the tools that EC2 provides.
You build your app so it uses shared resources (like a session state server, central location for storing user uploaded content), configure a server the way you like it, and capture a server image (AMI). You use this image when you configure AutoScaling to launch new instances based on server metrics (like CPU usage), and they would be automatically added to the load balancer when launched.
The last challenge is ensuring servers launched automatically are running your latest code. You can write a custom program to get the latest code from somewhere (like SVN) on server startup, or you can use something much simpler like Dropbox to handle the synchronization.

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).

Resources