Planet Claire

some say she's from Mars

Launching an umbraco website

by Claire 11/5/2009 5:59:00 AM

Here's a list of common tasks when launching a website, umbraco in particular, but a lot of these tasks are relevant to any asp.net website.

I've started this list for my own reference, it's not complete & not the last word either, but maybe it may help someone else.

1. Make sure you're in release mode

If you've got your relevant source files in a visual studio project then make sure that you build it in release mode. 

Also, ensure that debug="false" in the compilation element of web.config

The appsetting umbracoDebugMode is apparently allright to leave as "true" as it's not supposed to cause a performance hit.

2. Give the website full trust

Umbraco needs this in the web.config:


<system.web>
<trust level="Full" />
</system.web>

3. Configure a 404 page

Create a page in the website to handle 404 not found errors.  Add some navigation links to the home page, the search page or anywhere else that might be likely.  Add the node id of this page to the <errors404> element of /config/umbracoSettings.config

4. Configure a fallback error page

For any other unhandled exceptions that are not 404s you update the web.config like so:


<customErrors mode="On" defaultRedirect="~/error.aspx" />

5. Redirect the www subdomain to non-www or vice versa

Find out whether your client likes the wwws or not and then redirect accordingly, using the following syntax in /config/UrlRewriting.config.  Encourage your client to always use the preferred address in advertising and backlinks.


<add name="www" redirect="Domain" ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite" virtualUrl="http://www.yourdomainname.com/(.*)" redirectMode="Permanent" destinationUrl="http://yourdomainname.com/$1" />

6. Redirect old pages.

If this is a site rewrite there are probably old pages to redirect.  It's important to issue 301 "permanent redirect" so that search engines will know the old pages have moved & not disappeared completely.  

Luckily umbraco makes this easy, it uses the urlrewriting.net project which can be used to make search engine friendly & people readable urls, but is also very useful for the important 301 redirects.  Simply add the relevant entries to /config/UrlRewriting.config file.  Here's an example:


<add name="about" virtualUrl="^~/index_files/Page344.htm" destinationUrl="~/about-us.aspx" redirectMode="Permanent" ignoreCase="true" />

Note that for the above example to work your site must either be running on IIS7 or you must map the .htm extension to ASP.NET under IIS6.  This is because the requested file is .htm which isn't handled by default under IIS6.  Ditto for image files & .pdfs.

Here's an example with a query string.  In this case the products had moved but google still had the old pages in it's index.  Also need to include rewriteOnlyVirtualUrls="false" to make this work as products.aspx is a real page.


  <urlrewritingnet xmlns="http://www.urlrewriting.net/schemas/config/2006/07" rewriteOnlyVirtualUrls="false" >
   
    <rewrites>
      <add name="resources" virtualUrl="^~/products.aspx\?idCategory=044c6017-34c3-4454-865f-d142c1776ab6" destinationUrl="~/products.aspx?idCategory=b02e9f0b-10f6-4ec8-b462-2a9d08410817" rewriteUrlParameter="IncludeQueryStringForRewrite" redirectMode="Permanent" ignoreCase="true"/>

If you don't have access to the old website you might not know which pages to redirect, so I often just google the domain name to find out which pages google's got in it's index & redirect those.

7. Add ELMAH error logging & notifications

You need this, really!  There are some good instructions on Lee Kelleher's site, my setup differs a little in that I choose to use the same SQL server database that umbraco lives in.  To do that, you need to run SQLServer.sql on your database.  My web.config entries are shown below.


  <configSections>
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"/>
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah"/>
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah"/>
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
    </sectionGroup>
  </configSections>
  <elmah>
    <security allowRemoteAccess="yes" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ElmahDB" />
    <errorMail from="websiteEmailAddress" to="yourEmailAddress" />
    <errorFilter>
      <test>
        <jscript>
          <expression>
            <![CDATA[
                    // @assembly mscorlib
                    // @assembly System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
                    // @import System.IO
                    // @import System.Web

                    HttpStatusCode == 404
                    || BaseException instanceof FileNotFoundException
                    || BaseException instanceof HttpRequestValidationException
                    /* Using RegExp below (see http://msdn.microsoft.com/en-us/library/h6e2eb7w.aspx) */
                    || Context.Request.UserAgent.match(/crawler/i)                     
                    /*|| Context.Request.ServerVariables['REMOTE_ADDR'] == '127.0.0.1' // IPv4 only*/
                    ]]>
          </expression>
        </jscript>
      </test>
    </errorFilter>
  </elmah>
  <connectionStrings>
    <add name="ElmahDB" connectionString="server=servername;database=db;user id=userid;password=pwd" />
  </connectionStrings>
  <system.web>
    <httpModules>
      <!--
                Uncomment the entry below if you are using MS Ajax v1.0.x.x
                and want to capture errors during Partial Postbacks
                NB This is not required for the version of Ajax shipped with .Net Framework v3.5!
      <add name="MsAjaxDeltaErrorLog" type="Elmah.MsAjaxDeltaErrorLogModule, Elmah"/>
            -->
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
      <!--
        Uncomment the entries below if error mail reporting
        and filtering is desired.
        -->
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
      <!--<add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah"/>-->
    </httpModules>
    <httpHandlers>
      <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
    </httpHandlers>
    <authentication mode="Forms">
      <forms name="YourAuthCookie" loginUrl="umbraco/login.aspx" protection="All" path="/" />
    </authentication>
  <location path="elmah.axd">
    <system.web>
      <authorization>
        <deny users="?" />
      </authorization>
    </system.web>
  </location>

8. Give the login authorization cookie a unique name

In the web.config there's a section specifying what your login page is, if you're using forms authentication.  You should change the name of the cookie to something unique, otherwise you'll be sharing access with any other website which has the same cookie name. 

Incidentally you should also change the loginUrl to "umbraco/login.aspx" since that's the loginurl for umbraco.  Here's an example:


<forms name="AUTHWebsiteNameOrRandomString" loginUrl="umbraco/login.aspx" protection="All" path="/" />

You only need this section if you've got custom pages protected by forms authentication (such as elmah above).

9. Update the <mailSettings> element

Put some settings in here that are relevant to the production server, if indeed your website uses these settings, such as in a contact form.

10. Submit a sitemap to google

Not essential, but a good idea especially if it's a site rewrite.  Here are some suitable packages for umbraco, I use the Cultiv sitemap.

http://our.umbraco.org/projects/tag/sitemap#projectList

Submit the sitemap to google using google webmaster tools.

11. Google analytics. 

Add google analytics tracking code to the master template.  Set up an analytics user account for your client's email address.

12. Google maps

Don't forget to add your business to google maps, and embed the map on your website, if appropriate.

Tags:

Umbraco

blog comments powered by Disqus