0

I have Apache 2.2, and it's got modaspdotnet installed - the 2.2 version.

I followed the advice at Configuring ASP.NET MVC2 on Apache 2.2 using mod_aspdotnet, and the server works basically very well.

However, I'm trying to create custom extensions (e.g. file.customname, instead of file.aspx), similar to how Apache/PHP/htaccess can handle this. (I think it's mod_rewrite or .htaccess, forgotten which now!)

What would I do to get these custom file types (all serving .NET files) working?

The extensions are given custom names by me, simply for testing purposes

This is a tourism site [a testing one, btw], and it's working OK on localhost for basic pages, but I wanted to know how to do this.

How would I go about this? I've had a look on Google etc. but custom HTTP handlers was all I could really find!

Thanks

1 Answers1

0

Rather than trying to configure handlers for this, why not just use a rewrite. In your web.config add the following to your <system.webServer> section:

<system.webServer>
  <rewrite>
      <rules>
          <rule name="Rewrite custom ext" stopProcessing="true">
              <match url="^(.*)\.customname$" />
              <action type="Rewrite" url="{R:1}.aspx" />
          </rule>
      </rules>
  </rewrite>
<system.webServer>

This will rewrite:

http://example.com/somepage.customname -> http://example.com/somepage.aspx

If you're trying to use custom extensions in an ASP.NET MVC application then you could use a route:

{controller}/{action}.customname/{id}
Kev
  • 7,777
  • 17
  • 78
  • 108