Theme: default | dark | nature

RedirectModule

Download Download

Haven't you wished for an easy way to do redirects in ASP.NET, ala Apache? Well, there is!

In your web.config file, add a section like this:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="redirects" type="GLC.Tools.Configuration.XmlSerializerSectionHandler, GLC.Tools" />
  </configSections>
  <redirects type="GLC.Tools.Modules.RedirectConfig, GLC.Tools">
    <add targetUrl="^~/SomePlace/" destinationUrl="~/SomeOtherPlace/" permanent="false" ignoreCase="true" mode="remote" />
  </redirects>
</configuration>
...
</configuration>
<system.web>
    <httpModules>
      <add name="RedirectModule" type="GLC.Tools.Modules.RedirectModule, GLC.Tools" />
    </httpModules>
...
</system.web>

Valid values for the mode attribute are:

  • on - redirects always
  • local - redirects on localhost only
  • remote - redirects on non-localhost only
  • off - redirects never

Contact us today! Free consulting with no obligation.