Hi,
Thanks for posting in the community!
From your description, you'd like to manually generate the HttpContext
instance so as to do some unit test for ASP.NET web application with out
being host in IIS. And you're looking for some suggestions or information
on this.
If there is anything I misunderstood, please feel free to let me know.
Based on my research. Since the ASP.NET runtime process a certain web
request through a serials of progress which is called the ASP.NET runtime
pipeline. The pipeline start from the HttpRuntime which has a
processRequest method. And during the processRequest method, the ASP.NET
runtime finishs the whole progress of dealing with the certain request. The
HttpRuntime will generated an HttpContext instance which contains many
other helper compoent instances, here is the description in MSDN:
-------------------------------
The HttpRuntime object initializes a number of internal objects that will
help carry the request out. Helper objects include the cache manager (the
Cache object) and the internal file system monitor used to detect changes
in the source files that form the application. The HttpRuntime creates the
context for the request and fills it up with any HTTP information specific
to the request. The context is represented by an instance of the
HttpContext class
-------------------------------
For more detailed information, you may view the following reference in MSDN:
#The ASP.NET HTTP Runtime
http://msdn.microsoft.com/library/en...PNETHTTPRuntim
e.asp?frame=true
So if we'd like to manually faking the HttpContext, we need to first faking
the ASP.NET dotnet's runtime pipeline's task, that 'll be a complex work.
However, there're several tech articles which focus on Hosting the ASP.NET
Runtime outside the IIS such as in a winform or console application. Here
is some weblinks to them, you may have a look to see whether they'll help
you:
##Tech Articles on hosting ASP.NET runtime outside IIS
#Hosting ASP.NET Outside of IIS(especially for ASP.NET unit test)
http://hyperthink.net/blog/PermaLink...e58-9a7e25348b
8c.aspx
#Using ASP.NET Runtime in Desktop Applications
http://www.codeproject.com/dotnet/usingaspruntime.asp
#Using the ASP.Net Runtime for extending desktop applications with dynamic
HTML Scripts
http://www.west-wind.com/presentatio...netruntime.asp
Also, there're some thirty-party Unit Testing tools for ASP.NET web
application, some of them provide the convenient interfaces for ASP.NET web
application's unit test. Here is some web links to them:
##ASP.NET Unit Test Tools
#Get Test Infected with NUnit: Unit Test Your .NET Data Access Layer
http://msdn.microsoft.com/library/en...twithnunit.asp
?frame=true
#NUnitAsp ASP.NET unit testing
http://nunitasp.sourceforge.net/
Please check out the preceding items. If you need any further help, please
feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)