Hello Lance,
As for the "create a local server during runtime" question you mentioned,
do you mean you want programmtically start a local test webserver to run an
ASP.NET 2.0 web appliation from a specified file system path(directory) ?
Based on my understanding, the Visual Studio 2005 use the
"WebDev.TestSer ver.exe" application(ins talled with .net framework 2.0) in
the framework directory (C:\WINDOWS\Mic rosoft.NET\Fram ework\v2.0.5072 7).
When Visual Studio load and host a ASP.NET 2.0 web project in IDE, it
actually start this "WebDev.TestSer ver.exe" program and define the
application settings (such as physical directory path, virtual path , port
....) through commandline arguments. For example:
the following command (suppose the current directory is the .net 2.0
framework directory) will start an ASP.NET 2.0 web project hosted in the
local webserver, the application's physical directory is at
"d:\workspace\w ebprojects\WebA pp1", the web app will be hosted as the
"/WebApp/" virtual path, and listening on local port 8080:
WebDev.WebServe r /port:8080 /path:"d:\worksp ace\webprojects \WebApp1"
/vpath:"/WebApp1"
So we can visit the application's pages through the following local address
http://localhost:8080/WebApp1/xxx.aspx
Here is a good blog article describing the usage of the test webserver:
http://weblogs.asp.net/scottgu/archi...21/431138.aspx
In addition, if you want to programmaticall y start such a web application
in the test webserver, you can consider dynamically create a process
pointing to the "WebDev.WebServ er.exe" program and supply the paramters.
For example, here is a test .net code fragment that start a local webserver
session in a console application:
=============== =============== ====
class Program
{
static void Main(string[] args)
{
Run();
}
static void Run()
{
Process proc = new Process();
proc.StartInfo. FileName = HttpRuntime.Clr InstallDirector y +
"\\WebDev.WebSe rver.exe";
proc.StartInfo. Arguments = " /port:8888
/path:\"D:\\temp \\precompiled\\ testsite1\\upda table\"
/vpath:\"/testsite1\"";
proc.StartInfo. CreateNoWindow = true;
proc.StartInfo. UseShellExecute = false;
if(proc.Start() )
{
Console.WriteLi ne("local webserver started........ ");
}else{
Console.WriteLi ne("local webserver failed to
start........") ;
}
}
}
=============== =============== ==========
BTW, since the "webdev.webserv er.exe" is a winform application, I would
suggest you not try programmtically launch it in any non-interactive
service(such as ASP.NET application or windows service), because in such
service application, we can not interactively manage the created
"WebDev.WebServ er" application and may cause problem.
Hope this helps you. If you have anything unclear above, please feel free
to post here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial
response from the community or a Microsoft Support Engineer within 1
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 or complex project analysis
and dump analysis
issues. 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/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.