Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
We have web application portal that hosts multiple applications each in with its own IIS Website. So each time we adopt another machine to run our code, either developer workstation, or server, we have to manully create all of the websites for each of our applications, (and of course the list just keeps on growing). Is there an API call to create an IIS website, so that I could store all the necessary info in a database table and then write a winforms program that would check the table, and automagically create one IIS website for each record?
If you wanted to do this in a WinForms/Console application then I'd highly recommend looking at the System.DirectoryServices namespace.
There's some good documentation here:
Using System.DirectoryServices to Configure IIS (MSDN)
For example, to create sites and virtual directories:
Creating Sites and Virtual Directories Using System.DirectoryServices (MSDN)
The System.DirectoryServices namespace is a managed wrapper around the ADSI API's that the various IIS administration scripts use.
For more information on the various metabase properties you'll encounter I recommend this reference:
IIS Metabase Properties (MSDN)
If or when you move onto IIS7 then I recommend taking a look at the Microsoft.Web.Administration namespace and the APPCMD tool.
When IIS is installed onto a server, there are a number of scripts installed as well.
The one to look at is IISweb.vbs as this enables you to create a website from the command line. It's typically located in your %Windows%\System32 directory and you can run it from a command prompt using Cscript iisweb.vbs sitename /d hostheader
If you need to set further parameters on your website, then there are a couple of ways of doing it, either use the adsutil.vbs utility script or create your dummy website, export the settings to a file (save configuration to a file) and then when you need to create a new website, get your program to edit the settings and then import the configuration as a new website.
A good place to look for some of this is in the IIS 6.0 Administration guide
Obviously to do this, you will need to have the appropriate permissions on the servers where you are creating the new websites
Another useful script is adsutil.vbs in C:\Inetpub\AdminScripts
What version of IIS are you using? For IIS 6:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d3df4bc9-0954-459a-b5e6-7a8bc462960c.mspx?mfr=true
You can use SDC Tasks Library for that purpose. Here is a little manual.
I was looking for the same thing and I found sample code that creates a website in iis7 using C# and the Microsoft.Web.Administration API. Add a reference to C:\Windows\System32\InetServ\Microsoft.Web.Administration.dll in your visual studio project and run the code.
http://bloggingabout.net/blogs/dennis/archive/2008/05/16/programmatically-creating-an-iis7-site.aspx
You can create installators for your WebSites and run this insallators manualy or in batch. To create installators you can use WiX link text or standard Visual Studio Setup Project. Wix is more powerfull, but easiest way to start is to creating Visual Studio Installation project .
Related
I want to create an installer for ASP.net website.
Can I use NSIS to create an installer for my web application.
So I wanted to do followings through the installation wizard.
I need to install required databases in client computer.
I need to update the connection string in web.config file based the database.
I need to create ODBC connection and save their names in my project config file.
I need to create an application in application pool of IIS.
I need to host my project in IIS.
Can someone please let me know is it possible to do those things with NSIS?If possible how can I do it?
Thanking you.
There is no exact answer for you.
You need to create a customized installer with custom pages - but it is up to you how the custom pages look like and what they do.
You can achieve this with NSIS (even with Inno Setup which is a little easier to user) but we cannot post tutorial for you.
What you need to do is to start with simple installer (default one) and add custom pages to it. It page represent some functionality:
settings database connection values
writing configuration
creating app pool
setting IIS (there are some NSIS plug-in for working with IIS)
copying files etc.
Start with some NSIS example and add more and more functionality in it until it meets your requirements.
I'm having a lot of issues with the Visual Studio 2012 Publish feature.
I am looking an easy way to publish my Asp.Net MVC 4 application. Today I have my development machine and a web server. Every time I update the application, I have to manually copy and paste the files I want. This is a very cumbersome work.
I have tried VS2012 publish tool and encountered so many problems.
I am properly configuring ftp to work on passive mode but VS2012 keeps saying that passive mode is not activated.
Since there is no "checkbox" to alternate from passive mode to normal mode, I had to modify the xml file no set it to not operate with passive mode.
The deployment now succeeds, and now I'm receiving the following error:
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
Files\root\ee6c89b7\bf969ee8\App_Web_crjs1ytd.16.cs(33,0):
Error CS0234: 'The type or namespace name 'sistema_DocType' does not exist in the namespace 'gedaiapp.Models' (are you missing an assembly reference?)
There is nothing wrong with my application on my local machine and I am able to build it and run in the web server when I copy/paste the files, I do now understand why it doesn't work when I use the publish feature.
I have already tried deleting all files in the temp folder, cleaned the entire solution and project and rebuilt all.
Sorry to hear that you guys are having issues. You are correct Visual Studio does not support SFTP, but we do support FTPS.
We have an item on our uservoice site for SFTP support, but the vote count is currently very low (just has 6 votes). If you guys are interested in this support if you could vote on the item this will help me prioritize this so that we can investigate supporting this.
If you have any other feedback that you'd like to share with me regarding publishing please feel free to email me directly at sayedha[at]{MicrosoftDOTcom}.
This question is not easy to answer because it is not know if this is an internal corporate environment or a small environment and you're just copying a few files over the internet to a single server.
If you're in an internal corporate environment and have a large number of files/servers you need to copy to, you may want to look at replication (3rd party software or homegrown application).
I'm with you in that the publish tool is not up to current standards. My challenge with this tool is the lack of Secure FTP options for this application. This should be standard with any version of Visual Studio.
I'm currently using the IIS SFTP and Filezilla (SFTP) for my transport needs as the alternative to the lack of encrypted features in Visual Studio.
I'm basically wondering what the best way to deploy an Asp.Net Web Site is, mostly from the point of view of security. Right now, I'm trying to publish the website using Visual Studio 2010. Could someone direct me to a good tutorial on how to do this securely? For example, can it be done over an encrypted connection via Visual Studio? Is it necessary to install any software on the server to do this? Should I use a different program to open up an SSL (TLS) connection first, and if so, which program (does it come standard with windows)?
The server is running Windows Server 2008. Development is on Vista.
Many thanks in advance for any direction in this matter!
Andrew
I would publish the site to your local machine and file copy the files across to your test/production environment. As a rule we don't publish sites straight from VS to test or production.
For example you don't want to accidentally push things straight from dev into a live environment do you?
As far as the file transfer security goes you could use SFTP.
Note: First thing is to check with the owner of the server, as they often will provide you an FTP connection and will take care of configuring IIS.
If you want to add security, make a keyfile and sign your assemblies and consider running Dotfuscator on your dlls, the community edition is included in Visual Studio. Here is an earlier question where I've put more info on Dotfuscator.
If you have to do the deployment yourself, here's a few things to consider.
XCopy (easy)
MSI (have to create a setup program, you can do this easily in Visual Studio)
There is no security advantage in deploying using Visual Studio, but you can use Visual Studio to create a small setup program. One thing you want to make sure for security is DO NOT deploy any .cs files. Prepare your files, you should compile in Release mode, make sure debug is not enabled in your config file, keep your bin and it's dll, also the aspx, asmx, ascx, svc, css, js, and config files.
XCopy: Install a small FTP server, or use one your company alreayd has, this will allow you to get your files once you are logged into the target machine. You should be able to get an administrator account for the target machine, just ask the sysadmin of the domain, then log on using remote desktop, got to your ftp site, and download your files. Open IIS on the target machine, create a virtual directory and a pool. Copy your files to the location, configure your connection string to your DB if you use one, then test your website.
MSI: same process as above, except the setup will create the virtual directory and pool for you.
Here is extra info on best practices from the official ASP.Net website.
If you have some control on the server (e.g. to configure IIS7), you might want to look into Microsoft Web Deploy (new product just been released):
http://weblogs.asp.net/scottgu/archive/2010/09/13/automating-deployment-with-microsoft-web-deploy.aspx
Haven't tried it myself, but looks quite slick and it apparently encrypts the data being copied up, so might suit you.
I'm a total newbie to SVN and haven't been able to find an answer for the following situation.
I have an ASP .NET 2.0 web app that I am developing. I am using my local IIS as the development web server (i.e. not the Visual Studio web development server). My development environment is VS2005, Vista, IIS7, TortoiseSVN / AnkhSVN. VisualSVN is installed on the server.
My .sln files and class libraries, etc. are located in the **C:\Localsource\Projects\ProjectName** folder, and my .aspx files are in my **C:\inetpub\wwwroot\ProjectName** folder.
I can set up the repository for **C:\Localsource\Projects\ProjectName** fine, but can't think of a way to set it up for the IIS folder as well in the same repository.
What's the best way for dealing with this development environment in SVN?
Many thanks,
Ant
In a solution in Visual Studio you can have a class library project which is usually in a directory underneath the .sln file.
In this case he also has a web project within the solution but NOT underneath the .sln file in the file directory structure.
He will be attaching to this project via HTTP not via local file path.
IIS will manage this as http://localhost/webapp and by default will place it in c:\inetpub\wwwroot\webapp. The files in webapp folder will not be in the repo as they arent in the hierachy of the solution and the class library. This is his question how to sort it out.
My answer is to move http://localhost/webapp to point to a folder that is underneath the .sln file and adjacent to the class library directory then it can all go in the repo.
Seperating the class library and the the webapp is best practice to aide code re-use and decoupling the logic from the web site.
Can you not just point IIS to C:\Localsource\Projects\ProjectName and set the permissions?
Hmmm - Good point. It was set up like this when I got here, and Visual Studio always creates websites in the wwwroot folder, so I assumed wwwroot was just where they had to go.
Maybe I'll have to think about doing a little rearranging...
Thanks!
The IIS folder is not the output of the code base it is part of the application. It's not CGI output or anything but actually the scripts to run the app!
This is the .aspx pages that will have user controls and HTML to actually run the application. Its part of the applciation but split away from VS Studio solution.
The easiest way is to have a solution and then C:\Localsource\Projects\ProjectName\WEBSITE.
Point IIS at that folder as well.
OK, I may be being stupid here but.. Why do you need to add the IIS folder (i.e. the output of the code base) to your repository?
Update
I think I should clarify this a bit more.. What I mean to say is I am not sure why the ASPX is seperate from the project anyway? What is wrong with an Web Project and n Class Library Projects in a Solution, added to your repository.. You then publish on each new release..
If it is simply a case of "it might be easier to roll back the published output" then so be it, I was just curious as I have not seen many people actually work that way.
Deployment of solutions in this structure would be a lot easier as well..
I think you might want to separate this into two problems, following this recommendation from Dillorscroft.
First, with regard to the material on your development server that is published to the production site, I think you need version control for that. First so you can roll back any page, and you can also decide when you have a stable level of the development site that you want to extract to production. (I would get that from the source control system into a site image and then synchronize that image with the production site.)
So, for the first part, we are talking about versioning the web pages and all of the custom server-side material that supports the web site.
Secondly, With regard to the development of components that are used on the site, they need their own development projects, since it is the result that goes to the development site, not all of the source, libraries, etc. that the component is built with. So these will have their own project development tree (think of it as if you were building a library that is to be used by other development projects, although in this case the other projects are web pages). So the only thing that should show up in IIS is the "deployed" component to the development site.
There seem to be three critical questions for you:
How development of tests that need to go against the web site is handled and where that is version controlled (assuming they do not belong on the web site itself)
How easily you can arrange to make sure that all content on the development web site is kept under version control and checked-in and -out appropriately. (This has to do with the tools you use to edit web pages and other server-side gunk other than components developed off to the side.)
Easily taking developed components from the projects that produce them to the development site and have them be checked-in there.
My solution to (2) and to version control of the development web site is to use Visual Source Safe integration with IIS and FrontPage extensions that places the site under version control. Components produced from other development projects are mapped to the server project by VSS sharing.
For SVN, I speculate that (1) you want to see if there is an SVN adapter that IIS will recognize as an external source-control system and, either way, (2) have a discipline that takes delivery of components from their construction projects into the overall web site project.
Rob,
Why do you consider an .aspx file an output of the code base?
It is part of the code base. It's not an output after compilation for instance.
Just wondered?
I need a little help on this subject.
I have a Web application written in ASP.NET plus I have the .bak file of the SQL Express database, my question is: How can I install this in a simple click and go way in the client?
how can I write a script that will create a new database, restore the bak file into that database, set up IIS and ... well, that's it :)
I do this all manually, and I do this a lot, so I was just asking if there is a way to prevent do all this steps manually.
Thanks.
You could use WiX to create a .msi that you can use to install your application at your clients. WiX takes a bit to get used to, but once you get the hang of it, you'll meet your needs above, and be able to extend them as your application grows or increases in complexity from the installation point of view.
I read your question to mean you have several clients where you install your application, if that is not the case, and your app exists in one place, there are better solutions, and better people to give them to you!
While WIX is certainly very flexible if you aren't comfortable with the learning curve (and there is a bit of a learning curve IMO) then perhaps you should check out the Web Deployment Projects.
From the blog post:
Web Deployment projects can be used with either the "ASP.NET Web Site" or "ASP.NET Web Application Project" options built-into VS 2008, and provide a few additional build, packaging and deployment options for you to use.
Regarding the database, I'd suggest that you utilise the App_Data directory and just deploy the ".mdf" file. This would be easier than trying to create a new database and restoring a backup.