0

I've tried to rewrite a URL of a .aspx page, but i find all times this error :

error 500.23 : An ASP.NET httpHandlers configuration does not apply in Managed Pipeline mode.

premise: I'm using Visual Studio 2012 and c#

web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <httpHandlers>
            <add verb="*" path="viaggi/*.aspx" type="mioRewrite, mioRewrite"/>
        </httpHandlers>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" />
    </system.web>
    <appSettings>
        <add key="strConn" value="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\db_viaggi.mdf;Integrated Security=True" />
    </appSettings>
</configuration>

class mioRewrite inherited by the class IHttpHandlerFactory

public class mioRewrite : IHttpHandlerFactory
{
    public IHttpHandler GetHandler(HttpContext context, string requestType, string URL, string pathTranslated)
    {
        classe HttpContext
        context.Items["fileName"] = Path.GetFileNameWithoutExtension(URL).ToLower();

        return PageParser.GetCompiledPageInstance(URL, context.Server.MapPath("viaggi.aspx"), context);
    }

    public void ReleaseHandler(IHttpHandler handler) { }
}

I've used this method because some samples talk about it.

What I've to do to solve this error, and for creating a URL rewrite method?

1 Answer 1

2

The error is giving you your clue. Rather than running IIS in integrated mode, it needs to be run in classic mode.

Interestingly enough, this is an issue that my company had opened a ticket with Microsoft for. The IIS engineers confirmed that it appeared to be a bug and were unable to provide a resolution. IF using extensionless routes AND rewrite rules, we had to leave IIS in classic mode.

If running in IISExpress and not full IIS, you can still change to Classic Mode for your application with the following steps:

  1. Click on the web project in the solution explorer
  2. Press F4 to get the properties page to show up. You do not want the full, multi-tab properties page but rather the small properties window.
  3. Find the 'Managed Pipeline Mode' dropdown and change this to 'Classic'
Sign up to request clarification or add additional context in comments.

2 Comments

Where i can change integrated mode into classic mode?
@GianmarcoSpinaci I've updated my answer with IISExpress instructions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.