473,545 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a local server (i.e., localhost)

Is there any way to create a local server during runtime? For example, if
you add an existing Web Site to a Solution from within Visual Studio (by
right clicking the solution in the Solution Explorer, then selecting Add -
Existing Web Site...), then Visual Studio will create an ASP.NET Development
Server on a random port (e.g., http://localhost:1619/Test). Can a similar
thing be done during runtime with VB.NET? If not, is it possible to have a
folder act as a permanent local server?

Note that I am using VS.NET 2005 and WinXP Pro.

Thanks for any help!
Lance

Aug 2 '06 #1
5 20121
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.
Aug 2 '06 #2
Hi Steven,

Thank you so much for your excellent reply. Your sample code was exactly
what I was looking for and was tremendously helpful. If possible, I'm hoping
that you can help me with a few follow-up questions:

1. Is there any way to hide the icon that appears in the notification area
of the task bar?
2. Is there any way to programically stop the ASP.NET Development Server on
a given port (e.g., 8888)?
3. Is there any way to determine whether the ASP.NET Development Server is
already running on a given port?

Thanks again!
Lance
"Steven Cheng[MSFT]" wrote:
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.
Aug 2 '06 #3
Hi Steven,

Thank you so much for looking into my additional questions. Your help has
been exceptional and I am very grateful.

I would be interested to review the demo project that you created but I do
not see any way to access it (I am using IE to view the Newsgroup). You
recently sent me an email informing me of your reply. If it wouldn't be too
much trouble, could you please send the demo project as an email attachment
to that same address (or let me know some other way to get the demo)?

Thanks again!
Lance

"Steven Cheng[MSFT]" wrote:
Hi Lance,

Thanks for your reply.

As I mentioned in the last reply, the WebDev.TestServ er is designed as a
GUI/winform application which is recommended to host in an interactive
logon user session and hard to automate in a non-interactive service
session. For the new questions you mentioned, here are some of my
understanding and suggestions:

1. Is there any way to hide the icon that appears in the notification area
of the task bar?
=============== ========
I'm afraid this is limited by the webserver.exe since by default the
windows is not displayed and it is only the icon on taskbar that let the
user to interactive with the Webserver program. And I've lookup the
disassembly code of the webserver.exe, the icon is forced to display and
there is no configuration options.
2. Is there any way to programically stop the ASP.NET Development Server on
a given port (e.g., 8888)?
=============== =======
Since the webserver.exe is a winform application which has a main window,
when we manage it interactively, we could stop it by clicking the "Stop"
button on the winform. If you want to programmaticall y stop it, so far what
I've got is using WIN32 API to programmaticall y find the webserver.exe
application's main window and send some messages to the "Stop" button to
end it. This also require we're doing this in an interactive environment
(in a console or winform application that running under interactive logon
session).
3. Is there any way to determine whether the ASP.NET Development Server is
already running on a given port?
=============== =========
I think this is possible, since the port number is always append in the
webserver.exe applicaion main windows's Caption, we can capture the
caption of the window and pick the port number from the caption string. Of
course, we need to programmaticall y find all the existing webserver
application windows first.

For your convenience, I've created a complete demo project which contains
the necessary code to do the work for #2 and #3 above. Most of them require
calling win32 API through PINVOKE. I've attached this project in this
thread, you can get it if you're using Outlook Express to visit the NNTP
newsgroup. If you have problems accessing it, please feel free to let me
know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights
Aug 8 '06 #4
Hi Lance,

Glad to hear from you. Sure, I will send you the demo project through
email(the one I send the notify mail). Please let me know if you still have
problems getting it.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Aug 8 '06 #5
Got it and it works great. Thanks again for the amazing help!

Lance

Aug 9 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1441
by: Ogger | last post by:
Hello, I'm trying to develop a COM local server with python using Mark Hammond's win32 extensions, but I have problems when I want to fire an event. The COM server has a worker thread and I want to fire an event from this worker thread passing an argument to the event that is another automation server (served from the same local server)....
2
42862
by: Asad Khan | last post by:
Hello, I was using MySQL till a few days ago just fine. Now everytime I try to run it using mysql.exe, I get the following error: "can't connect to mysql server 'localhost' (10061)" What can I do to get rid of this? (What is 10061?)
1
7035
by: BGuy | last post by:
When I am attempting to connect to SQL Server 2000 on my local server, I get the following error: "Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection" My connection string is as follows: string strCnn = "server=fredflintstone;uid=sa;pwd='';database=DBPass" For my SQL Server account I am using Local...
0
1553
by: Mr. Land | last post by:
Hello. I'm having trouble creating a new Web project using VS .NET 2003 on the local default web. I've done a lot of research about this and found a lot of suggestions, but none of them seem to have worked in my case so far. I'd appreciate any help anyone can offer! Here's the problem: When attempting to create a new ASP.NET Web...
4
4131
by: Nathaniel Sherman | last post by:
Alright, folks, here's the deal... I'm working on migrating a classic ASP website to an ASP.NET codebase. At the heart of the site is a MySQL database. To make sure an "in-process" program doesn't screw up the live site, I run a local IIS webserver on my XP Pro (AMD XP 2500+, 512MB DDR RAM) machine, which resides behind an XP ICS gateway...
2
1902
by: Neil | last post by:
I created a stored procedure to update a table on a linked server from a table in my local server. Both servers are SQL 7, and the linked server is accessed through the Internet. When I tried to create the stored procedure using an Access 2000 ADP file, the save command would continually time out. However, when I went into Enterprise Manager...
1
2178
by: Eyalbiber | last post by:
Hi, I've just installed sql server 2005 on my cpu i think it's the enterprise edition and i have few problems : 1.i can't find my local server anywhere(this is my main problem) b.t.w : i'm connected to a server that isn't local and everything work fine there when i try to set a new database engine and then - > new - > database registertion...
1
2131
by: Adrienne Boswell | last post by:
This is the strangest thing. On my local beta server (WinXP Pro SP3, PHP 5.2.3), I am getting an unexpected $end. On the production server, I am not. The files are identical. Just for shits and giggles, I made a new folder on my local machine, copied all the files from the production server, opened it, and again got the same thing. The...
1
3155
code green
by: code green | last post by:
I have had 3 seperate procedures running happily for a couple of years that I now wish to merge into one. 1. Collect list of email addresses from Access on local server. Write these addresses to a CSV file. 2. FTP the CSV file from local server to remote server using FTP program 3. Insert email addresses from CSV into MySql and send out an...
0
7459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7411
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7749
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5965
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1871
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
695
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.