In ASP. NET 2.0, the global. asax file does not have post-code. How can I move pages in Globa. asax to the code file?

Source: Internet
Author: User
On the Asp.net page, learn how to solve this problem in the instance of the castle container. You can set this function as follows:
<% @ Application inherits = "mvpsample. Web. mvpsamplehttpapplication" Language = "C #" %>

Mvpsamplehttpapplication code
Using system;
Using system. Web;
Using Castle. Windsor;
Using Castle. Windsor. configuration. interpreters;

Namespace mvpsample. Web
{
/** // <Summary>
/// Summary description for mvphttpapplication
/// </Summary>
Public class mvpsamplehttpapplication: httpapplication, icontaineraccessor
{
/** // <Summary>
/// Implements <see CREF = "icontaineraccessor"/> so that castle facilities
/// Can gain access to the <see CREF = "httpapplication"/>.
/// </Summary>
Public iwindsorcontainer container {
Get {return windsorcontainer ;}
}

/** // <Summary>
/// Provides a globally available access to the <see CREF = "iwindsorcontainer"/> instance.
/// </Summary>
Public static iwindsorcontainer windsorcontainer {
Get {return windsorcontainer ;}
}

/** // <Summary>
/// Code that runs on application startup
/// </Summary>
Public void application_start (Object sender, eventargs e ){
// Initialize log4net here if you're using it

// Create the Windsor container for IOC.
// Supplying "xmlinterpreter" as the parameter tells Windsor
// To look at web. config for any necessary configuration.
Windsorcontainer = new windsorcontainer (New xmlinterpreter ());
}

Public void application_end (Object sender, eventargs e ){
Windsorcontainer. Dispose ();
}

Public void application_error (Object sender, eventargs e ){}

Public void session_start (Object sender, eventargs e ){}

/** // <Summary>
///
/// </Summary>
/// <Remarks>
/// The session_end event is raised only when the sessionstate Mode
/// Is set to inproc in the web. config file. If session mode is set to StateServer
/// Or sqlserver, the event is not raised.
/// </Remarks>
Public void session_end (Object sender, eventargs e ){
}

/** // <Summary>
/// Gets instantiated on <see CREF = "application_start"/>.
/// </Summary>
Private Static iwindsorcontainer windsorcontainer;
}
}

By the way, we will introduce a useful tool.

Parses parameters between Asp.net pages in a strongly typed manner, which is called pagemethods.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.