Hi
I am trying to write a Custom Rewrite Provider that use ODBC rather than the SQLClient as we are using MySQL database server. I am following the tutorial here http://learn.iis.net/page.aspx/804/developing-a-custom-rewrite-provider-for-url-rewrite-module/
This is the error we are getting
Error Summary
<div> </div>This is the code for the provider
using System; using System.Collections.Generic; using System.Text; using System.Data.Odbc; using Microsoft.Web.Iis.Rewrite; public class ODBCProvider: IRewriteProvider, IProviderDescriptor { private string connectionString; private string storedProcedure; public void Initialize(IDictionary<string, string> settings, IRewriteContext rewriteContext) { if (!settings.TryGetValue("Connection", out connectionString) || string.IsNullOrEmpty(connectionString)) throw new ArgumentException("ODBC Connection string is required and connot be empty"); if (!settings.TryGetValue("Command", out storedProcedure) || string.IsNullOrEmpty(storedProcedure)) throw new ArgumentException("ODBC Command string is required and connot be empty"); } public string Rewrite(string value) { OdbcConnection dbcon = new OdbcConnection(connectionString); OdbcCommand dbcom = new OdbcCommand("CALL " + storedProcedure + "(?)", dbcon); dbcom.CommandType = System.Data.CommandType.StoredProcedure; dbcom.Parameters.AddWithValue("?", value); dbcon.Open(); string url = (string)dbcom.ExecuteScalar(); dbcon.Close(); return url; } public IEnumerable<SettingDescriptor> GetSettings() { yield return new SettingDescriptor("Connection", "ODBC connection string"); yield return new SettingDescriptor("Command", "ODBC stored procedure"); } }
With the following settings in the web.config
<rule name="NavigationMappings" stopProcessing="true"><match url="(.*)" /><conditions><add input="{ODBCProvider:{R:1}}" pattern="(.+)" /></conditions><action type="Rewrite" url="{C:1}" /></rule><provider name="ODBCProvider" type="ODBCProvider, ODBCProvider, Version=1.0.3866.30779, Culture=neutral, PublicKeyToken=18cc6a842eca6b31"><settings><add key="Command" value="url_rewrite_navigation" /><add key="Connection" value="Driver={MySQL ODBC 5.1 Driver};Server=localhost;Port=3306;Database=decode_cms_dev4;User=user;Password=password;Option=3;" /></settings></provider>
I know the MySQL Driver is installed because we use it for the main connection for the rest of the website. So any ideas why this isnt working?
The computer testing this out is Windows 7 with IIS 7.5 x64
Thanks
Dan