当前位置: 动力学知识库 > 问答 > 编程问答 >

asp.net - Unable to open solution containing website due to port being less than 1024?

问题描述:

I recently had to remap my solution to a new directory, upon trying to reload the solution in visual studio 2010 I get the error message:

"Cannot open Web Site 'http ://localhost/XXX'. You must run Visual Studio in the context of an administrator account to create IIS Express sites with ports less than 1024."

This is strange because as far as I can tell, the port defined in the solution file is well above port 1024. And the only advice I can find requires that I open the solution in VS (funny little catch 22 right?).

The solution worked before I remapped and re-downloaded the solution from TFS.

This is in remote apps, so I don't have access to actually run VS as an administrator.

网友答案:

Figured out a solution a while ago, but forgot to post the answer here just in case someone else stumbled across this one day.

If you open the solution file containing the project, you need to remove any instance of 'localhost' where the website in question is referenced. This seems to do the trick.

My guess is VS sees the 'localhost' and assumes you're trying to actually open a site on the local machine, or bind it to that address. Which would explain the port error.

网友答案:

I had this error after upgrading a website from VS 2005 to VS 2012. cDecker32's answer is correct, but I'm adding some supporting details...

The site was declared like this in the VS 2005 sln file:

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "C:\...\EMR\", "EMR", "{6E950F28-C219-492C-B9A3-5480D70475FB}"

VS 2012 changed it during the upgrade to reference localhost:

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "http://localhost/EMR/", "http://localhost/EMR", "{6E950F28-C219-492C-B9A3-5480D70475FB}"

After relaunching VS 2012 with "Run As Administrator" (per the error message's instructions), 'localhost' was removed from the project name, but kept in the path:

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "EMR-Site/EMR", "http://localhost/EMR", "{6E950F28-C219-492C-B9A3-5480D70475FB}"

This allowed the solution to load, but the site failed to run at this point; studio complained that you need admin rights to use ports < 1024. I believe it assumes localhost means IIS on port 80.

Manually renaming the path to "\EMR" in both the Project definition and the Source Control section allowed the site to run as it did in VS 2005.

网友答案:

I had this issue when I opened the project in VS2013 but still no problem in VS2012. I was able to resolve the issue by doing the following:

Open the project file in a text editor and change the following line in the project file:

<AutoAssignPort>False</AutoAssignPort> -> <AutoAssignPort>True</AutoAssignPort>

Also, I removed the following line:

<DevelopmentServerPort>81</DevelopmentServerPort>
分享给朋友:
您可能感兴趣的文章:
随机阅读: