Ensuring an acceptable online user experience while republishing to a live site - asp.net-mvc

It's pretty much known that publishing to a remote location using VS2008 is a an exercise of great patience and faith.
As long as a 'publish' begins (using VS2008, publishing an MVC site), that site might be down from the first file that is successfully transferred. The problem being that unreliable internet access, or interesting error messages () can break the site, and require restarting.
It's understood that there is little to do from the VS2008 end. The question then:
What strategy can I use to ensure that there is an acceptable user experience during the 'downtime'? (e.g. "This site is currently under maintenance...")

A lovely feature of ASP.NET/IIS is that if you place a file named app_offline.htm in the root of the web application, all requests will redirect to that file. This would include requests for images, stylesheets, scripts, etc.. so you'll need to condense all media for the page into the page itself.
In fact, while Visual Studio is in the process of publishing your web application, it will place this file in the root of the application and remove it when the publish is complete. While Visual Studio doesn't allow you to customize the contents of its app_offline.htm, you can take the application offline yourself simply by uploading that page.

Related

Dynamic Page Content on Precompiled Azure Web App

I am just about to launch an Azure Web App (aka Azure Web Sites) and have a quick question.
I've noticed there was a pretty significant lag on using the site when I publish my site from Visual Studio. Each page(/controller?) appeared to be compiling only when it was first accessed so it made the site feel very slow at least for a few minutes. I want to avoid that so I am used the "Precompile" option when I Build and Publish from VS. This seems to work and, although there is still some initial lag after publishing, it's much better than it was.
My question is this: Because this is a new site and we are constantly adding functionality and fixing bugs, I would like to have a section on my main _Layout page which I can quickly edit with a notification (ie. "Site will go down in 15 minutes for maintenance."). The problem is that I don't want to go through the whole Build/Publish process to get that content up to the site. Is there a way that I can include some file / content (page_alert.html) in my _Layout.cshtml page that can be edited in something like the Azure App Service Editor? Because of the precompiled nature of the site, all my .cshtml files now just say "This is a marker file generated by the precompilation tool, and should not be deleted!" in the App Service Editor.
Thanks!
When you choose the Precompile option, you can also check 'Allow precompiled site to be updatable'. That will then allow you to update individual .cshtml files which will be compiled on the fly, while the rest is still precompiled.
See doc for details.
I think I found a solution that will work from another SO posting.
https://stackoverflow.com/a/14634578/1359788
#Html.Raw(File.ReadAllText(Server.MapPath("~/content/somefile.html")))
I can edit that somefile.html in the App Service Editor and it works

TFS VNext build Delete Files task need to exclude one file

I need to use the delete files task in a VNext build definition (TFS 2015).
asp.net c# web app on an IIS 7.5.
I found that we can use exclusion pattern, but it's not working.
How can I make this work?
Delete all files except app_offline.htm.
**;-:app_offline.htm
If it can't work like that, how can I make sure that the users will get the app_offline.htm file even when I'm deploying the application.
I first created a build to copy the app_offline page and another build to delete it. My problem is in the middle.
thanks
Leaving a site hosted in IIS online but showing a maintenance page is less than ideal. Since it's still processing the application's web.config, users will get intermittent errors during the deployment, depending on what files are currently changing and whether IIS is able to load the assemblies referenced in the web.config.
A better approach is to deploy a static maintenance page to a separate web site.
Then your deployment process can just be:
Stop real site
Start maintenance site
Deploy real site
Stop maintenance site
Start real site
Assuming the two sites have the same bindings, users will seamlessly be redirected to the maintenance site for the duration of the deployment.
Dealing with a site that's load balanced across multiple web servers is a slightly different scenario with additional options and considerations, but I'm assuming that's not the case here.

What is needed to open up an MVC project on a remote server?

I'm new to web development so please be kind. Anyway, I'm writing a web page in visual web developer 2012 and have hit a roadblock. I've got lots more experience with writing console applications. When writing one of those and you build the application, the bin folder is populated with the files that are required to run the application, most notable the .exe . But when I build the page all I get is .cshtml files, which when opened all it does is open the code in my web browser. I tried to get an answer on another web site but all that i got was "open it up on a web server". That doesn't make any sense to me. Please help.....
You open the project locally on your workstation, as you would any other project. But when you're ready to publish the project you would send it to a web server.
Visual Web Developer (being akin to Visual Studio, no?) should have a small built-in web server of some sort which it uses when you execute your project in debug mode. (There are more details than that, but that statement alone should be true enough to get you debugging.) That's fine for ongoing development work, but not for the resulting production application.
Analogous to installing a console application on a target workstation, you would need to publish your web application to a web server. This server may coincidentally by the same workstation on which you develop the code, but that's not a requirement.
A "web server" in this case can be one of many things. Your computer (running IIS, most likely), a server hosted somewhere, a service in the cloud, etc. And "publishing" could mean any number of things as well. Uploading the files, using built-in publishing tools in the IDE, even just committing the files to source control and allowing an automated publish service to fetch them (I do this a lot in Azure web sites).
Ultimately, the way you execute a web application that's been published isn't by double-clicking on a file anywhere. The .cshtml files, as well as any other needed files (binaries, config files, images, style sheets, etc.) are stored on a web server somewhere and you would "run" the application by making a request to that web server, which takes the form of browsing to a URL in your web browser.

How to publish an ASP.NET MVC website

I've a site that I'd like to publish to a co-located live server. I'm finding this simple task quite hard.
My problems begin with the Web Deploy tool (1.1) giving me a 401 Unauthorized as the adminstrator because port :8172 comes up in the errors and this port is blocked - but the documentation says "The default ListenURL is http://+:80/MsDeployAgentService"!
I'm loathe to open another port and I've little patience these days so I thought bu66er it, I'll create a Web Deploy package and import it into IIS on the server over RDP.
I notice first that Visual Studio doesn't use a dialog box to gather settings, or use my Publish profiles but seems to use a tab in the project properties, although I think these are ignored when importing the package anyway?
I'm now sitting in the import wizard with Application Path and Connection String. I've cleared the conn string as I think this is for some ASP stuff I don't use but when I enter nothing in the Application Path, the wizard barks at me saying that basically I'm a weirdo because most people publish to folders beneath the root site.
Now, I want my site to be site.com/Home/About and not site.com/subfolder/Home/About and I think being an MVC routed site that a subfolder will introduce other headaches. Should I go ahead and use the root?
Finally, I also want to publish a web service to www.site.com/services/soap which I think IIS can handle.
While typing this question, Amazon have delivered my IIS 7 Resource Kit, and I've been scouring the internet but actually I'm getting more confused.
Comment here seems to show consensus opinion that Publish isn't for production sites and that real men roll their own.
ASP.NET website 'Publish' vs Web Deployment Project
...I guess this was pre- Web Deployment Tool era?
I'm going to experiment on a spare box for now but any assistance is welcome.
Luke
UPDATE
The site was imported (to the root) manually with Web Deploy and it worked. If you get the error "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' " its because your app pool is 4.0 and should be 2.0.
If you are using VS 2010, may I recommend Scott Hanselman's Web Debloyment Made Awesome?
http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyYoureDoingItWrong.aspx
Even if you are using VS2008, there are nice concepts there that will probably help.
I've experienced the same frustration and trouble with this as well. Coming from a Java web background where we can package everything as a single WAR and toss it on the server, the deployment process with ASP.NET seems archaic.
I currently have a python script that uses FTP to transfer the needed files to my test instance on the remote server. I have another python script that transfers those files to my live site. These scripts are smart enough to take care of differences between some of the configuration files etc..
I've found it much easier than trying to setup permissions or using the Microsoft deploy tools.
Hi you can use filezilla software to upload

Disable Visual Studio Web Server Directory Browsing

I'm using Visual Studio's built in web server to test and EPiServer applicaiton. When I have the app running in IIS, if I hit the root of the virtual directory, EPiServer will take over and server the defaul page to me. Using the Visual Studion server (which I am doing for license reasons with the SDK), it always gives me the 'Directory Listing' view of my site. Does anyone know how to configure this web server to not allow the directory listing/browsing?
Additional Information:
This problme only seems to effect the root of the visual studion web server (i'll call it cassini from here on in). As an example, if I run a site from localhost:6666, then what I will find is that localhost:6666/en/ will work just fine and the EPiServer VPP will know what it is doing. If I use localhost:6666/, then the VPP never kicks in (or so it seams). It seems to me that when the root of cassini is hit, it checks to see if the page exists (which it does not as I have no default). If it decides that the page does not exist, then it serves up the directory listing, rather than 404. The first thing to do for me is to dispable directory browsing in cassini, then look at why the VPP is not being actioned correctly.
So I suppose the base of the question is: Is there a way to modify these settins in Cassini when it is Visual Studio starting everything off?
(EPiServer may be a red herring, but just in case, it's CMS version 5)
Further Update
I managed to get hold of the source for Cassini 3.5 and gave that a whirl. 3.5 works just fine and behaves like IIS in this instance. I.e. the lack of default document does not lead to a Directory listing, rather if allows the HTTP handlers to kick in and then EPiServer does the rest! So the question is, can I achieve the same in Visual Studios effort at a web server?
Make sure you have a ~/Default.aspx file. It won't render, but it's needed in cassini for the virtual path providers to get a chance to handle the request for '/'.
Of course, if you make it anyway you might as well use it for the start page :-)
Even if you could get the server to not show the directory listing, could you get EPiServer to take over?
EDIT: From comments
The fact that it works with /en/ makes me think this is something that Microsoft could fix. I suggest you ask the vendor if they have a workaround. If they do not, then please create a suggestion at http://connect.microsoft.com/visualstudio/. Be sure to specify details about EPIServer, URL to the vendor, etc.
Be clear that it works with /en, but you want a setting permitting it to work at the root.
Once you create the suggestion, please edit your question to include the link to the suggestion you create. That way, others reading your question can vote on how important they think this is.
The EpiServer part confuses me. However, if you are asking how to set the default page for the VS development server (based on the Cassini code), you're expected to do that in the project properties (right click on web project), Web, Start Action, Specific Page, foo.aspx.
I suspect the cassini/VS development server doesn't have a default page feature-- the source code for the cassini server (the ancestor of the VS development server) is on the web and you can check that and add a default page by building a custom version. And it doesn't have a very long list of other features that IIS has.
Which EPiServer version are you running?
Did you install it using EPiServer Manager?
There has always been some differences in the configuration between running the site at the root of a host name or as a (virtual) directory.
Check the site settings block in web.config and make sure you have a default.aspx at the project root.

Resources