automate app_offline.htm file in asp.net web application - asp.net

I want to delete the app_offline page(app_offline.htm) from the root of the IIS application when the work completed.How to automate this deploy and delete the app offline page in iis directory.
I tried read some artciles about MSdeploy but could not get that .
Can we do it by running some commands to auto deploy and delete the app_offline page from the server root directory ?
Please help me on this. I found below two commands to run
msdeploy.exe –verb:sync
-source:contentPath="[Project folder]\App_offline.template.htm"
-dest:contentPath="[IIS application path]/App_offline.htm",
computerName="[Destination web server]"
for delete
msdeploy.exe –verb:delete
-dest:contentPath="[IIS application path]/App_offline.htm",
computerName="[Destination web server]"
But not get how to run the above commands

You can also try use cmd.exe, It is located at C:\Windows\System32\cmd.exe, more information you can refer to this link: Web Deploy (MSDeploy).

Related

Create directory in web deploy package?

I have an ASP.NET WebForms application which I would like to publish to a Web Deploy package and deploy using the deploy.cmd script generated as part of the Web Deploy package. This basically works fine but I have one problem.
My application generates image files which are stored in a temporary directory as part of the web site (basically a subdirectory of the IIS site's physical location called temp). However, whenever I deploy my site using the deploy.cmd script, this directoty is deleted. Instead, I would like the deploy script to make sure the directory is present and that the IIS user has access to it. Is this possible to do with Web Deploy out of the box?

How to run .bat file on server after web deploy publish

I am using Web Deploy for publishing an ASP.NET MVCwebsite in Visual Studio 2010.
Is there any way to run a .bat file on server after this publish automatically?
See: Post Publish Events
You could create a Windows Service that runs on your IIS box and uses the FileSystemWatcher to monitor changes to your web root path and when it detects a file change run a batch file.

Deploying ASP.net on IIS in windows 7

I've never actually used IIS, and I'm pretty new to the whole ASP.net thing too.
Basically, I've created a RESTful service using a VS2010 ASP.net project.
I'm not sure how you get that ASP.net application (which runs great on Visual Studio) to run on an IIS server.
It's pretty easy with a Java dynamic web project and Tomcat, but here I'm not sure how to begin.
Do I simply deploy the binaries to a directory?
Thanks!
ther are some possibilities
the easy one
create under c:\inetpub\wwwroot\ a new directory for your app
in the iis manager, configure this directory (create an application, set the right .net version, ... ). than everything you need is to copy all your files into that directory and thats it.
but you can also create a msi file, if you don't have the direct access to the server.
hth
For best testing you application use IIS 7.5 express on you development machine and set this:
project->Properties->Web->Use Local IIS Web Server
After testing under local IIS you can deploy you project to real IIS by using Build->Publish 'Your project'
Simplest way is deploying to File System in some folder and copy its content to created site folder, associated with IIS Virtual directory. To create Sites and virtual directories, see this:
http://www.bloggingdeveloper.com/post/Creating-IIS7-sites-applications-and-virtual-directories-using-Internet-Information-Services-Manager.aspx
http://mvolo.com/blogs/serverside/archive/2007/07/12/Creating-IIS7-sites_2C00_-applications_2C00_-and-virtual-directories.aspx

Precompilation for Deployment

After exploring Precompilation for Deployment topic I want to enhance my build process. Now, what I do is:
prepare web site using Web One Click Publish, for instance to c:\www\app directory, and that directory is available in IIS via app (localhost/app)
I launch aspnet_compiler.exe -v app c:\www\appprecompiled -f
Now I have ready precompiled application in c:\www\appprecompiled and everything is fine. However my application is quite big, and Publishing it (step 1) take about 5 minutes from scratch. So I wonder if it is possible to avoid step one , and perform step 2 (precompilation) with source folder pointing to solution folder. I tried something like this:
aspnet_compiler.exe -v codeapp c:\code\app -f
Where c:\code\app is the folder with web.config etc files, basically it's a project with web site and that folder is avaliable via http://localhost/codeapp.
But when launching that command, I get errors about missing global.asax or web.config errors:
C:\code\app\obj\debug\package\packagetmp\web.config(18):
error ASPCONFIG: It is an error to use
a section registered as
allowDefinition='MachineToApplication'
beyond application level. This error
can be caused by a virtual directory
not being configured as an
application in IIS.
And for the record, I use Application, not Virtual Directory.
So is there a way to perform precompilation on a plain web site folder?
I used
aspnet_compiler -p
physicalOrRelativePath -v / targetPath
from http://msdn.microsoft.com/en-us/library/ms227976(v=VS.80).aspx and removed obj folder prior to executing it, and precompilation works :)

MSDeploy and "site under maintenance" page

I am new to MSDeploy as well as IIS admin.
In order to show a "site under maintenance" page we are looking at two alternatives.
1) Have an app_Offline.htm page and sync it to the server when maintenance starts.
2) Create a separate folder with a totally different site (which can show a lot more dynamic information than what we can with the app_offline page). During maintenance, it is being suggested that we change the virtual folder mapping of the site to point to this other folder while we work on updating the site.
Is there a way to change the virtual folder to point to another folder using MSDeploy? Is there any other way to do this via a script rather than having to go to each server and manually change the folder ?
Set app_offline using MSDeploy
What we've done in the past is to script our deployments using Msdeploy.exe. We execute 3 commands.
The first command deploys the app_offline.htm page.
msdeploy -verb:sync -source:filePath=c:\location\app_Offline.htm -dest:filePath=c:\site\app_Offline.htm
Second we actually deploy the site using that same "sync" verb but using a package.
Third we'll remove the app_offline.htm using MSdeploy.
msdeploy -verb:delete -dest:filePath=c:\site\app_Offline.htm
You can execute msdeploy across multiple servers using the "computername" destination switch. Like:
msdeploy -verb:sync -source:filePath=c:\location\app_Offline.htm,computername=sourcemachine -dest:filePath=c:\site\app_Offline.htm,computername=destmachine
You can find more information about all the different parameters for using msdeploy via command line here: http://technet.microsoft.com/en-us/library/dd568991%28WS.10%29.aspx
Creating a virtual directory using MSDeploy
If you still want to create the virtual directory what I'd suggest is creating a powershell script on each destination sever that would do this for each server. Your powershell script would have something like this in it:
New-Item 'IIS:\Sites\Default Web Site\VirtualDirName' -type VirtualDirectory -physicalPath c:\test\virtualDirectory1
You can find more info about using powershell for this here:
http://learn.iis.net/page.aspx/433/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools/
Then execute using msdeploy utalizing the "runcommand" provider. You would execute this line per server.
msdeploy -verb:sync -source:runCommand="net start createvirtualdir.ps" -dest:computername=destmachine

Resources