The problem comes from the forum, there are netizens such requirements, in the ASHX call ASPX.cs a method or function.
In a Web site, there may be more than one ASPX page.
Declare the method inside the Aspx.cs as Public,ashx want to call, and do not know which Aspx method is inside.
is a certain aspx.cs has quoted this ashx, this ashx also do not know the method of calling in the current ASPX.
In order to solve the above problem, Insus.net creates an interface (interface)
In the site, create an ASPX with the name called A.aspx. No code is written in A.aspx, but within A.aspx.cs, you need to implement the interface that you just wrote:
Now we write a handler: The name is b.ashx:
Test run to see:
The following content is added and collated in 2014-04-11 08:10:
In the development of the Web site, many times want to PageA.aspx.cs to call PageB.aspx.cs within the method, or in turn, PageB.aspx.cs want to call the method in PageA.aspx.cs.
Under normal circumstances, it is not possible to instantiate the call after. If you refer to this method, it can be solved.
As an example:
Define a say method in PageB.aspx.cs:
Then PageA.aspx.cs to call the Say method inside the PageB.aspx.cs:
Web page Execution Results:
Since the use of reflective reflection, it can also save the interface.