Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6839787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:45:41+00:00 2026-05-26T23:45:41+00:00

I am having quite a few problems with custom extensions and intercepting existing handlers.

  • 0

I am having quite a few problems with custom extensions and intercepting existing handlers.

What am I trying to do

Based upon persisted options, I would like all ‘virtual’ extensions to be handled by set handlers. All pages are dynamically built, and no actual files exist on the site. The site populates the content, forms the html output and returns it as the web result.
This is required as I am setting up a fat/thin relationship between 2 servers. The thin server will simply pass on the request to the fat server – where the request is processed and response issued back down the line.
The project is for a dynamic multi-domain content management system. The thin server may not be .net compatible (hence the external request), but will be .net optimised (hence the need for handlers).

The Problem

What I want is to re-route existing extensions – aspx; php; html.
I have achieved this in my local environment using a custom HttpModule which sets the appropriate handler. I have explored setting the tag in config, but the the extensions are re-routed using dynamic rules that are persisted.

As mentioned, this solution works on localhost.
When uploaded, the .Net extensions are handled by the module correctly but any custom extensions or non-.net extensions return a 404 error.

Seeking an alternative, I have experimented with routing within Global, but this dis not work either.

I have also attempted to use to register the custom extensions… but each are met with the same result – 404 not found.


Global Routing attempt:

public class Global : System.Web.HttpApplication
{

    void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {

        routes.Add(new Route("{action}.sqs", new SqlRequestHandler()));
    }

.Config (for handler and module attempt)

    <system.web>
      <compilation debug="true" targetFramework="4.0" />
      <httpRuntime requestValidationMode="2.0" />
      <customErrors mode="Off"/>

      <httpHandlers>
        <add path="*.sqs" verb="*" type="CmsMapper.VirtualHandler, CmsMapper" />
        <add path="*.sql" verb="*" type="CmsMapper.VirtualHandler, CmsMapper" />
      </httpHandlers>

      <httpModules>
        <add name="SisBerCMS" type="CmsMapper.VirtualModule, CmsMapper" />
      </httpModules>
  </system.web>

  <system.webServer>   
      <modules runAllManagedModulesForAllRequests="true" />
      <modules>
        <add name="SisBerCMS" type="CmsMapper.VirtualModule, CmsMapper" />
      </modules>

      <handlers>
        <add path="*.sqs" verb="*" type="CmsMapper.VirtualHandler, CmsMapper" name="sqsHandler" />
        <add path="*.sql" verb="*" type="CmsMapper.VirtualHandler, CmsMapper" name="sqlHandler" />
      </handlers>
  </system.webServer>

Custom Module (CmsMapper.VirtualModule)

    if (extentionMap != null)
    {
        // note that extentionMap.ExtentionType is a predetermined enum
        switch (extentionMap.ExtentionType)
        {
            // If the extention is banned then pass back a generic message
            case ExtentionType.Banned:
                this.WriteTextResponce("Invalid extention detected:" + extentionMap.Extention);
                break;

            // Remap .Ajax requests to the ajax handler
            case ExtentionType.Ajax:
                this._app.Context.RemapHandler(new AjaxHandler());
                break;

            // Remap session query or sql requests to the sql handler
            case ExtentionType.SessionQuery:
                this._app.Context.RemapHandler(new SqlRequestHandler());
                break;

            // if the extention is not ignored, re map to the virtual page handler
            default:

                bool isManagementServer = this._app.Context.Request.Url.Authority != VirtualModule.RESPONSE_SERVER;
                bool isPostRequest = !String.IsNullOrEmpty(this._app.Context.Request.Form[HtmlRequest.RequestOrigin]);
                bool isGetRequest = !String.IsNullOrEmpty(this._app.Context.Request.QueryString[HtmlRequest.RequestOrigin]);
                bool isIgnored = extentionMap.ExtentionType == ExtentionType.Ignore;

                if ((isPostRequest || isGetRequest) && !isIgnored)
                {
                    this._app.Context.RemapHandler(new VirtualHandler());
                }
                else
                {
                    this._app.Context.RemapHandler(new ExternalRequestHandler());
                }

                break;
        }
    }

All the handlers are pretty standard implementing the following:

public class SqlRequestHandler : IHttpHandler, IRequiresSessionState, IRouteHandler

Again, the preferred method – HttpModule – works on my localhost machine. This could be a server config issue (in which case I’m looking for a work around), but the fact that the .net extensions are being handled is strange – as this would imply that issues with medium trust should not apply, however issues regarding extension handling on the server may take priority over the .net application.

The server is shared hosting (therefore I am unable to alter the machine.config files), is IIS6 using 4.0.

Thank you for any suggestions on how to resolve this issue.
Mike

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:45:42+00:00Added an answer on May 26, 2026 at 11:45 pm

    You need to configure web site in IIS 6.0 to route all extensions (including extensionless paths known as wildcard extension mapping) to ASP.NET ISAPI dll (and disable the check for file exists).

    You can of course do this mapping selectively only for those extensions that you want to route via ASP.NET code. But wildcard mapping will be more useful in case you don’t have predefined set of extensions.

    In the absence of such mappings, IIS will not forward requests for unknown extensions to ASP.NET (and routing code will not even come into picture) – rather IIS will pass the extension to default (static file) handler that will issue 404 if file is not present.

    See this article that describes these steps (for ASP.NET MVC but the same applies to your case): http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
    Near the end of article, author has given how to add wildcard script map

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been having quite a few problems trying to use Microsoft.SqlServer.Types.SqlGeography . I know
I am having quite a few problems saving a C# control to a bitmap
Having read up on quite a few articles on Artificial Life (A subject I
Quite a few apps support plugins. Are there any downsides to having a large
We are having a few problems understanding how best to use NHibernate. We typically
I'm having quite a problem deciding how to serve a few Python scripts. The
I have been having some problems with this for a few days now... I
I've read about quite a few people having a problem with this and I've
I'm having quite a bit of pain inserting and deleting UITableViewCells from the same
Having been a PHP developer on LAMP servers for quite a while, is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.