Debug VS2010 website at root instead of subdirectory
So I inherited an IIS website and I am not familiar with the tools. When I run project it wants to start up at localhost/myApp/. If I do not have IIS configured to start up in this location then debugge开发者_如何学Pythonr fails to attach. However, I have code that assumes my site is on the root directory. I am on IIS 7 and Win 7 x64.
when I debug the website from inside VS2010 how do I tell it that my website is located at localhost/? My project is the one highlighted in red.
To debug the website using root with visual studio in a website project do the following:
- Push F4 to bring up the properties window.
- Change the Virtual Path to '/' and then your good to go.
The reason you can't change the starting url is because of the way the project was added to the solution. When the Web Site project is listed as a url instead of as a local file system path, it is because the project was added to the solution by using Add > Existing Web Site > Local IIS
option. When a project is added in this manner, then Visual Studio.NET will not allow you to change the path.
In order to change the path, you should remove the project from your solution and add it back to the solution using Add > Existing Web Site > File System
. Use the Add Existing Web Site dialog to navigate to the project folder (the same folder that is used as the Physical Path for the site in IIS). When the project is readded it will be listed in the Solution Explorer by the local path (i.e., E:\inetput\myapp) instead of the localhost url. From there, all of the options under Start Options should be configurable.
You have to switch your solution to use local IIS instead of the in-memory ASP.NET Development server
- In the .sln, right click the project for your web app, select Properties
- Select the Web tab
- In the "servers" section you'll have 3 options.
- Select "Use Local IIS Web Server"
Then you can modify hosting properties such as the url
- On the same tab, you'll now have two options which can get you where you need to be
- Project URL
- Override Application root URL
- Right click on your web project file
- Select properties
- Select the web tab (from the tabs on the left) half way down there is a section called servers there you can customise the web server you are using and the URL it should be directed to when you start debugging.
Is it possible that you are working with an ASP.Net Web Site as opposed to an ASP.Net Web Application?
If you have a folder called "App_Code" then it's a Web Site and will have fewer options.
Intro to Web Application Projects (has an info table):
http://msdn.microsoft.com/en-us/library/aa730880(v=vs.80).aspx
Might help you migrate if it is a Web Site and you want more control:
http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx
I've now had to do this often enough that I thought I would add more explicit steps. These are based off of the accepted answer from rsbarro. Steps are for VS2010
- Right-click on existing website and choose Remove
- Right-click on the solution and choose Add | Existing Website | Choose folder
- Right-click on new item in solution explorer and choose Property Pages
- Under Start Options tick Custom Server and enter
http://localhost
- Right-click on new item in solution explorer and choose Set as Startup Project
精彩评论