Hi Marvin,
We need to confirm your requirement firstly.
After the request is processed into the web application, the current
HttpApplication instance would be created or selected by the
HttpApplicaitonFactory automatically, we cannot control this action. The
current HttpApplication is unique for the web application. Although we can
create a HttpContext and HttpApplication in the global.asax, it is
recommended that we define some properties in current HttpContext and
access them, but it is impossible to replace current instance with the
custom one. That means there is no public function that can get the custom
HttpApplication instance defined in the global.asax.
However, if you want to run Unit-Test or run the web application from other
programs (for example, a win form program). We can define custom
HttpContext firstly and then process request ourselves. Thus, the web
application will use the custom HttpContext as its current instance.
For example:
Request.Context =CustomContext;
HttpRuntime.ProcessRequest(Request);
--
Sincerely,
Zhi-Qiang Ni
Microsoft Online Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
MSDN Managed Newsgroup support offering is for non-urgent issues where an
initial response from the community or a Microsoft Support Engineer within
2 business day is acceptable. Please note that each follow up response may
take approximately 2 business days as the support professional working with
you may need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
--------------------
| Date: Fri, 20 Nov 2009 14:57:47 +0100
| From: Marvin Landman <
[email protected]>
| User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
| MIME-Version: 1.0
| Subject: Re: How to get global.asax build result or a new application
instance?
| References: <
[email protected]>
<#
[email protected]>
<
[email protected]>
<#
[email protected]>
<e#
[email protected]>
<
[email protected]>
| In-Reply-To: <
[email protected]>
| Content-Type: text/plain; charset=windows-1252; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: catv-80-98-131-226.catv.broadband.hu 80.98.131.226
| Lines: 1
| Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP05.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:94431
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thank you very much for your response.
|
| HttpApplicationFactory.GetApplicationInstance works but it is an
| internal method and I wonder if there is a more proper way of getting an
| application instance or the type defined in global.asax.
|
| But I am also interested in making HttpApplicationFactory to select a
| different application than the one declared in global.asax (i.e. a
| custom one) if that's possible.
|
| Marving
|
| Zhi-Qiang Ni[MSFT] rote:
| > Hi Marvin,
| >
| > What my understanding of your requirement is that, you would like to
get
| > the instance when the Application is started by the
HttpApplicationFactory
| > instead of the instance of the current application. We know that when
the
| > first request for the application arrives, the factory class extracts
| > information about the type of the application (the global.asax class),
| > creates the application state and fires the Application_OnStart event.
The
| > factory selects a HttpApplication instance from the pool (like your
said, a
| > internal method HttpApplicationFactory.GetApplicationInstance) and
assigns
| > it to process the request. If no objects are available, a new
| > HttpApplication object is created. So, the requirement is seemed like
how
| > to control the HttpApplicationFactory to select the different
application
| > instances(maybe built by ourselves) for the request from the same
| > process(the pool).
| >
| > Please correct me if I'm misunderstanding you.
| >
|