简体   繁体   中英

Setting up development environment for ASP.NET MVC

I'm from PHP background. I used to use Apache, MySQL and PHP for web development. I'm just starting asp.net mvc.

  1. I've Visual Studio 2008 Pro SP1 & .NET 3.5 SP1 already installed on my computer.
  2. So, I installed ASP.NET MVC 1.0
  3. Created a "ASP.NET MVC Web Application" project
  4. when I hit F5 it gives error Unable to connect to the ASP.NET Development Server

No wonder. In this process I didn't setup the webserver.

Can I use apache here? I guess IIS is the default. Where is it? How do I configure it? What is the WebRoot directory for IIS server? Where can I find it?

On searching for "Unable to connect to the ASP.NET Development Server" I found this solution:

Step 1: Select the “Tools->External Tools” menu option in VS or Visual Web Developer. This will allow you to configure and add new menu items to your Tools menu.

Step 2: Click the “Add” button to add a new external tool menu item. Name it “WebServer on Port 8010” (or anything else you want).

Step 3: For the “Command” textbox setting enter this value: C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\WebDev.WebServer.EXE (note: this points to the web-server that VS usually automatically runs).

Step 4: For the “Arguments” textbox setting enter this value: /port:8010 /path:$(ProjectDir) (or any port you like)

Step 5: Select the “Use Output Window” checkbox (this will prevent the command-shell window from popping up.

Once you hit apply and ok you will now have a new menu item in your “Tools” menu called “WebServer on Port 8010”. You can now select any web project in your solution and then choose this menu option to launch a web-server that has a root site on port 8010 (or whatever other port you want) for the project. You can then connect to this site in a browser by simply saying http://localhost:8010/ . All root based references will work fine.

Step 6: The last step is to configure your web project to automatically reference this web-server when you run or debug a site instead of launching the built-in web-server itself. To-do this, select your web-project in the solution explorer, right click and select “property pages”. Select the “start options” setting on the left, and under server change the radio button value from the default (which is use built-in webserver) to instead be “Use custom server”. Then set the Base URL value to be: http://localhost:8010/

But there is no C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\WebDev.WebServer.EXE such file on my system. Did I forget to install something? Please help me in running my "Hello World" application.

EDIT:

I'm using Windows XP SP2 and logged in as a user with Administrative previlages.

from this Unable to connect to ASP.Net Development Server issue

  • Disable IPv6

Done!!

  • Make sure there isnt an edit in the hosts file for localhost

There is no single entry in my hosts file (%SystemRoot%\\system32\\drivers\\etc\\hosts) with 'localhost' in it.

  • Check firewall/virus settings to allow connections to/from devenv.exe

I tried by disabling the firewall/antivirus

  • If you can preview in the browser make sure the URL in the browser uses the same port number as the port number shown in the ASP.NET dev server taskbar icon.

No, Actually there is no such dev server taskbar icon.

  • Try setting a fixed, predefined port in project properties

Tried it. But no positive result.

Solution:

After trying everything. I came to conclusion that WebDev.WebServer.exe may be corrupt. So, I've replaced C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\9.0\\WebDev.WebServer.EXE with a fresh copy : http://www.4shared.com/file/116555696/ff3b0dc8/WebDevWebServer.html

It worked!! :)

ASP.NET Development Server is a mini web server that comes with Visual Studio. The idea is that you wouldn't need to set up IIS for development.

Checkout this question for possible solutions. Mostly I would make sure that localhost is not redirected in your hosts file and also that you are not doing anything funky with a local firewall app that might be blocking certain ports on localhost.

You cannot, as far as I am aware, use Apache. You could configure it to use IIS in your project Properties->Start Options screen by pointing it to a valid IIS directory you have set up.

Edit: Also try this:

  1. Open a command window (cmd.exe)
  2. Run C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\9.0\\WebDev.WebServer.Exe /port:8080 /path:c:\\mywebpath\\ (swap out c:\\mywebpath for the path to your app)

You should notice the WebDev server start up in your task bar. You should then be able to browse to http://localhost:8080/default.aspx (or whatever your page is).

If that doesn't work try the same thing but using http://127.0.0.1:8080/default.aspx . If this works but localhost does not then something is redirecting your localhost traffic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM