Sandip's Programming Zen

An attempt to share tech/coding experiences

Starting Asp.Net Development Server Manually

with 18 comments

It is often required by developers that they have to just browse the web site under development, but unfortunately there is no straight forward way to start the development server, you have to open visual studio and run your application.

However, you can do that by invoking server by manual command. I have made a Batch File utility which will do just that. Following is the code, put that in a text file and save it with a .bat extension (you may have to change paths according to your environment).

call “C:\Program Files\Microsoft Visual Studio 9.0\vc\vcvarsall.bat”
webdev.webserver /port:6464 /path:”c:/yourappfolder/yourapp”

In above line, port number can be anything in the range of 0 to 65000.

One thing is missing still, I would love to open the website in the browser as soon as I run this batch file, tried few things but does not work. Let me know if some one knows how to do that.

Written by Sandip

April 5, 2008 at 12:42 pm

Posted in .Net

18 Responses

Subscribe to comments with RSS.

  1. You can add this line at the end of your .bat file:

    C:\Program Files\Internet Explorer\iexplore “http://localhost:6464/yourapp”

    This line will start an IE instance with the website you defined. In the above example “http://localhost:6464/yourapp” will be opened.

    onur

    April 20, 2008 at 12:05 pm

  2. Thanks for your comment.

    Actually I have tried this out before, it does not launch IE for the given path.

    Sandip

    April 21, 2008 at 8:24 am

  3. I am getting this error when I try to run the .bat file

    ‘webdev.webserver’ is not recognized as an internal or external command,
    operable program or batch file.

    Where can I find Webdev.Webserver.exe? It’s not in the C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\
    Thanks!

    Alex

    June 21, 2008 at 11:26 pm

  4. later edit – found in C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0, but it is now crashing after I try to view it in browser.

    Alex

    June 21, 2008 at 11:34 pm

  5. Hi Alex,

    Are you first running following batch file?
    call “:\Program Files\Microsoft Visual Studio 9.0\vc\vcvarsall.bat”

    On regular command prompt you can not directly run webdev.webserver command as it is part of .Net framework, so to do that we must first “start” all necessary .net services and then run that command. so first line “calls” the .net framework’s batch file and then run our command to start web server.

    Sandip

    June 22, 2008 at 9:33 am

  6. Yes, my .bat file look like this:

    call “C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat”
    “C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.exe” /port:3900 /path:”D:/Alex/FACULTATE/Licenta/Proiect/huddi.NET/huddi.NET”

    When running, I see something like “Setting environment for using Microsoft Visual Studio 2008 x86 tools”. Then the server starts and the command has not returned, meaning it is still doing something. When I try to “View in web browser”, it opens the page but then the dev server crashes.
    Any idea? Thanks!

    Alex

    June 22, 2008 at 9:45 am

  7. Ah, found the problem: the path to the project should have had backslashes, not slashes. It works fine now. Great post, thanks again!

    Alex

    June 22, 2008 at 5:02 pm

  8. Hello,

    it works with opening only one port but my .bat-file should open two ports.

    How can I do it?

    CrafterP

    July 25, 2008 at 5:43 am

  9. Do you mean, you are putting two such lines with different port numbers?

    webdev.webserver /port:6464 /path:”c:/yourappfolder/yourapp”

    If you do then normally it should work, if does not then check if the port number you are using is allowed as per your local network policy.

    Sandip

    July 25, 2008 at 6:04 am

  10. if I try this commands in the cmd it works but it doesn’t work in the .bat-file

    this is my script:
    ————————

    call “C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat”
    “C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.exe” /port:1732 /path:D:\Test\ToolOne /vpath:/ToolOne
    “C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.exe” /port:2811 /path:D:\Test\ToolTwo /vpath:/ToolTwo

    CrafterP

    July 25, 2008 at 6:45 am

  11. Great article, very useful, thanks Sandip

    Manuel Giuliano Rios

    October 1, 2008 at 11:14 pm

  12. What if there are more than one .aspx pages in our application.How to then specify it after path variable

    Kumar Gaurav

    October 22, 2008 at 2:41 pm

  13. Kumar,

    The purpose is to start the application server, and it will always consider default.aspx (or whichever your default page) as it’s starting page.

    For you, different batch files can be made for different pages.

    Sandip

    October 23, 2008 at 7:19 pm

  14. Is it possible to change path to csc.exe? I want to run it from virtual hard drive.

  15. Hi Viktar,

    This is about running the code but I think you want to compile your project from command line. Check the following link for help.

    http://www.codeproject.com/KB/aspnet/devaspoutvs.aspx

    Sandip

    November 22, 2008 at 5:34 am

  16. The reason that starting a web browser from the batch file does not “work” is probably because the batch file never gets to the line that opens the browser because it is waiting for the webdev.webserver to finish. In other words webdev.webserver is a blocking call.
    Execution of the batch file does not continue until the webdev.webserver process finishes.

    One workaround would be to put the “start” command before the call to webdev.webserver. Example:

    call “C:\Program Files\Microsoft Visual Studio 9.0\vc\vcvarsall.bat”
    start webdev.webserver /port:6464 /path:”c:/yourappfolder/yourapp”
    firefox http://localhost:6464/

    Josh

    April 9, 2009 at 12:57 am

  17. For visual studio 2005

    start /B %WINDIR%\Microsoft.NET\Framework\v2.0.50727\webdev.webserver.exe /port:4955 /path:”E:\wwwroot\myweb” /vpath:/myweb

    start iexplore http://localhost:4955/eMarket

    Tajammal

    May 24, 2009 at 2:58 pm

  18. you can also do like this. this will automatically start webserver using windows explorer context menu, will pick random port.

    prashantaware.blogspot.com/

    Prashant

    September 16, 2009 at 2:13 pm


Leave a comment