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.