0

For legacy reasons we have urls with '.page' in them like so:

/controller.page/action

We have re-rewritten the app, and so the urls are no longer in this format and we need to 301 redirect them, which needs to happen in code. The new app is a MVC 3 & .net 4 and is IIS 7 hosted.

The issue is, IIS is seeing the .page in the url, then looking for a handler for this extension not finding it, and then returning a 404.0 and not handing the request off too .net where we can then preform the redirect.

Any idea on how to resolve this?

I tried adding this handler in the web.config:

<add name="LegacyMVC" path="*.page" verb="*"
    type="System.Web.Mvc.MvcHttpHandler" preCondition="integratedMode" />

But I get this error:

System.NotSupportedException: Specified method is not supported.
   at System.Web.Routing.StopRoutingHandler.GetHttpHandler(RequestContext requestContext)
   at System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContextBase httpContext)
   at System.Web.Mvc.MvcHttpHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Community
  • 1
  • 1
Dan
  • 29,100
  • 43
  • 148
  • 207

1 Answers1

2

Create a Handler Mapping in IIS for your .page, which sends the requests to the MVC handler. You can then handle the requests with MVC routing

IIS edit handler

Dan
  • 29,100
  • 43
  • 148
  • 207
Jon Eastwood
  • 813
  • 10
  • 22