Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which .NET class does represent the main CONTROLLER class for WebForms?

I was studying a bit of Java, when I was taught about a way to implement a controller class, whose resposibility is to redirect the request to an Action, which perfoms a specified work. That was the way I learnt;

@Override
protected void service(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {

    try {
        String clazz = req.getRequestURI().replaceAll(req.getContextPath() + "/", "").replaceAll(".java", "");
        ((Action)Class.forName("com.myProject.actions." + clazz).newInstance()).execute(req, res);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

I know that WebForms also works with HANDLERS, which are kind of actions. For example, each .aspx page inherits from a Page object which is a handler for that specified page.

What I couldn't figure out is, which class does get request first and translate it to the specified action (page handler)? Is it a WebForms feature(implementation) or its a IIS resposibility? So, which class represent the main controller for WebForms?

Thank you very much.

like image 348
Renato Gama Avatar asked Aug 28 '26 22:08

Renato Gama


1 Answers

I would suggest reading about HttpApplication class, especially MapRequestHandler.

The MapRequestHandler event is used by the ASP.NET infrastructure to determine the request handler for the current request. For more information, see How to: Register HTTP Handlers.

ASP.NET Application Life Cycle Overview for IIS 7.0

like image 167
Jakub Konecki Avatar answered Aug 30 '26 13:08

Jakub Konecki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!