Compatibility Checking in WebMatrix - When the checker reports failures

Intro

In WebMatrix V1 we released a new feature called Publish Compatibility. This feature inspects your local application for dependencies and requirements. It will then runs a set of tests against your remote website. The idea is to identify any potential issues with your remote internet server missing components that are must have for your site to run.

For example, if your site is using a database (say Microsoft SQL server or MySQL) the remote server must support accessing these databases or else your site will simply fail after publishing.

 

Ben Byrd and Bilal Aslam published a great article taking you through this feature:

http://blogs.iis.net/bilalaslam/archive/2010/11/12/new-feature-in-webmatrix-beta-3-publish-compatibility.aspx

 

Server

If you are using shared hosting from the spotlight category, typically it means that the server already supports the applications from the WebMatrix gallery. If you setup a server yourself, you will have to ensure you have all the dependencies in place. Here is a set of articles by Bilal Aslam and Simon Tan on how to setup a server, please note that the target audience for this is a hosting provider setting up production servers.

 

http://learn.iis.net/page.aspx/951/install-server-components/

http://learn.iis.net/page.aspx/984/configure-web-deploy/

http://learn.iis.net/page.aspx/952/validate-your-server-configuration/

 

How it works

Compatibility checker works in two ways, the first one used for databases and ASP.NET version is using Web Deploy. Web Deploy tries to connect to the databases on your remote and also adjusts your ASP.NET version to match your site’s preferences (from 2.0 to 4.0 or vice versa).

 

These tests will succeed if Web Deploy can access your remote database, which means either Microsoft SQL Server or MySQL is installed and configured correctly on the remote server.

For the ASP.NET version, the compatibility checker will run a piece of code on the remote server (Web Deploy provider) and first check if your application pool matches the one on the remote site. If they don’t it will attempt to adjust them.

 

The second way is by publishing test pages to a secure location on your site. If publishing of these files succeed, WebMatrix then tries to hit (or request) these pages. For each dependency WebMatrix tries to verify that the page is behaving as expected thus reflecting that the dependencies are available on the remote site.

Just to clarify, we do not put any user info in these pages, and they will not appear to the standard user browsing your site. Further more we delete them as soon as the compatibility check is done, so within a few seconds of starting the tests, they are gone from the server.

 

Why does the test return Unavailable

Most commonly it simply means the remote server does not support all the dependencies your site needs. But there are a few other cases I wanted to highlight, they mostly revolve around the Simple HTML Page test.

 

This test does a very simple task, it uploads a hello world html page then tries to retrieve it. So how can such a simple test fail? The Not Available result will only come up if we successfully managed to upload the files.

 

Well this can mean one of two things, the files got uploaded but not where you expected them to go. Or the files where uploaded to the right spot, but for some reason your remote site is redirecting the request away from them.

 

Mismatch

image

image

 

The most common reason is that your destination URL is pointing to a different location from where your files got published to. If you use the Web Deploy protocol verify that the site name and server combination match the destination URL. In FTP you need to look at the server and the site path.

 

Redirection

We also found that if there are rewrite rules in the root of the site, the compatibility checker will not pick up the changes. This case will typically happen only after you published something to the site and now you are trying the compatibility again. Since we are trying to find static files, we cannot get them anymore and report failure. Typically in this case all the request based tests will fail (Simple HTML, PHP, PHP Drivers, etc.)

Here is a solution for this issue:

Find the following file it’s going to be in your program files (or program files(X86) if you run a 64bit OS).

Microsoft WebMatrix\config\Compatibility\Web.Config

Back the current one you have.

Open it in an editor and replace the content with the following:

<?xml version="1.0"?>

<configuration>

  <system.webServer>

    <directoryBrowse enabled="false" />

    <rewrite>

      <rules>

        <clear/>

      </rules>

    </rewrite>

  </system.webServer>

</configuration>

 

This will disable all URL rewrite rules for the subfolder where the files are getting published to and will not affect the rest of your site.

 

What if this still doesn’t resolve my issues

Here is a way to get more information, what this will turn on tracing for Publish Compatibility. Then feel free to post the trace to the WebMatrix forums at http://forums.iis.net

Word of caution, make sure you backup the files and make the changes accurately or WebMatrix might stop working.

 

Close all instances of WebMatrix

Go to the Program Files/Microsoft WebMatrix folder.

Find the file called: webmatrix.exe.config

Back it up

Open the file in a text editor (preferably an XML editor)

 

The file should start something like:

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"  />
  </startup>
  <runtime>
 
Right after the configuration tag add the following 

<system.diagnostics>

    <sources>

      <source name="PublishCompatibility"

        switchName="sourceSwitch"

        switchType="System.Diagnostics.SourceSwitch">

        <listeners>

          <add name="FileWriter"

              type="System.Diagnostics.TextWriterTraceListener"

              initializeData="C:\FilePathtoYourtace.log">

              <filter type="System.Diagnostics.EventTypeFilter"

              initializeData="Verbose"/>

          </add>

          <remove name="Default"/>

        </listeners>

      </source>

    </sources>

  </system.diagnostics>

 

Make sure you replace the highlighted text with where you want your files to get stored.

Now run compatibility checker again and send us the results from that file.

Don’t forget to restore the configuration file back after you are done.

 

for more info: http://msdn.microsoft.com/en-us/library/system.diagnostics.textwritertracelistener.aspx

 

Summary

Publish Compatibility is a powerful tool to help you verify that your live site will work as expected. When publish compatibility is reporting an error, most likely there is either a limitation on the remote server or your Publish Settings are not correct.

If you encounter issues outside of what is described above I want to encourage you to go to the forums and tell us about it.

 

 

1 Comment

  • How did you find that WebMatrix has the PublishCompatibility diagnostic source? I wonder if they have others I can use to track my problem with publishing. That WebMatrix can't determine file changes and is always reporting zero files changed.

Comments have been disabled for this content.