Is it possible to change ASP.NET so that runat = "server" is no longer required?

I know why runat = "server" is currently required ( ASP.NET why runat = "server" ), but the consensus is that it is not needed if you include a simple project in your design (I agree of course).

Can you modify, extend, decompile, and recreate, intercept, or otherwise change the behavior of how ASP.NET parses ASPX and ASCX files so that runat = "server" is no longer needed? For example, I'm guessing the Mono version might be forked to achieve this goal.

In case specific requirements are helpful, the following are the main points:

  • When parsing, when namespace tags (like asp) are configured, the default runat property of the element is on "server"
  • During parsing, when customized namespace tags are encountered (like asp), if an element's runat property is available, then that value should be used instead of the default
  • Introduced a new page-level parameter (can be set in a page directive or web.config) that specifies the default runat value for a specific namespace tag
+2


a source to share


2 answers


I'm afraid you'll have to change the whole page parser to do this, and I don't think that's possible.

On the other hand, you should be able to create your own. See buildProviders Element and BuildProvider class . You should be able to create your own build provider for .aspx pages and use that to replace the built-in provider.

Unfortunately, the class PageBuildProvider

that ASP.NET uses is internal, and the class PageParser

it uses to parse pages is sealed

. You will be completely alone.



Keep in mind that I runat="server"

've been in ASP.NET for 10 years now, and I think you'll see that this won't change anytime soon.

You will also lose support for Designer, but you might not care.

0


a source


As far as I know, there are not enough deep hooks in the process of processing ASP.NET pages to do this. I don't know how to override or extend the parsing or handling of the actual aspx / ascx code.

While ASP.NET is quite flexible and allows you to override many of the default behaviors (like how to save / load the ViewState, where the session is stored, etc.), this is not one of them.



However ... technically the Page object is just another HttpHandler. You can write your handler and do whatever you want. All you have to do is implement everything the Page class does, and then use this extra functionality. :) Alternatively, pull out the Reflector and walk through the ProcessRequest method of the page object and see where it actually parses / initializes the objects. declared in aspx and you can figure out how to implement the functionality you are looking for. But I suspect you will be wasting your time.

0


a source







All Articles