views:

20

answers:

3

What I would like to have is a mapping between a custom file extension to a class that is not System.Web.UI.Page but a class of mine that inherits from System.Web.UI.Page.

i.e.:

*.aspx -> System.Web.UI.Page *.my -> My.Package.MyClass (inherits from System.Web.UI.Page)

I know I can map any extension to be treated like .aspx but I can't find the way to do what I have in mind.

Thanks d

A: 

You need a ASP.Net HTTPHandler for this.

I know you mentioned that you already inherit from System.Web.UI.Page but also look into the lighter weight ASHX Handler

kervin
A: 

Hey,

A custom page handler, but also any ASP.NET Page can inherit from your custom base class, so you wouldn't necessarily need to do a handler. You could just have the code-behind pages all inherit from My.Package.MyClass instead.

Brian
Yes, it's what I usually do, but I wanted to apply it also when I don't need a separate code file.I can't use a custom handle because I need markup and asp.net tags.
Darko Romanov
Yes, like you mentioned, this would work for ASPX: <%@ Page Language="C#" Inherits="MyPackage.MyClass" %> in your original response, you mentioned a custom .my extension, which uses a handler. You could theoretically point the .my extension to the same PageHandlerFactory class that the .aspx points to, giving you the custom extension and now your new page construct...
Brian
A: 

I think I was trying to build a castle when I just needed a hut.

When I'm in case of a .aspx page without a separate code file I just have to add the Inherits directive, making it pointing to my custom class, like this:

<%@ Page Language="C#" Inherits="MyPackage.MyClass" %>
Darko Romanov