[英]How to make a .net web application run as the root application in Visual Studio
I've been converting some .net "Web Sites" to "Web Applications". 我一直在将一些.net“网站”转换为“Web应用程序”。 This has been going along smoothly.
这一直顺利进行。 One of the steps that I perform each time I do a conversion is I go to the web section of the project properties and set the virtual directory.
我每次执行转换时执行的其中一个步骤是转到项目属性的Web部分并设置虚拟目录。
So far, I've set up 到目前为止,我已经成立了
- http://localhost/site1 - http:// localhost / site1
- http://localhost/site2 - http:// localhost / site2
- http://localhost/site3 - http:// localhost / site3
Finally, I've received the task of performing a Web Site -> Web Application conversion on the web site that resides on the root directory of our servers. 最后,我收到了在网站上执行网站 - > Web应用程序转换的任务,该网站位于我们服务器的根目录中。 However, if I specify http://localhost/ as the virtual directory in Visual Studio, it results in an error.
但是,如果我将http:// localhost /指定为Visual Studio中的虚拟目录,则会导致错误。 How do I go about converting the root web site to a web application project in Visual Studio?
如何在Visual Studio中将根网站转换为Web应用程序项目?
This feels like a KLUDGE, but I've found a way to do what I want. 感觉就像一个KLUDGE,但我找到了一种方法来做我想要的。
First, open the Web settings tab of the project properties in Visual Studio. 首先,在Visual Studio中打开项目属性的Web设置选项卡。 Set the virtual directory to
http://localhost/someDirectory
. 将虚拟目录设置为
http://localhost/someDirectory
。 You cannot set it to http://localhost/
at this point as an error will result. 此时您无法将其设置为
http://localhost/
,因为将导致错误。 Build your web site to the directory (on disk) where you want to host it from. 将您的网站构建到您要从中托管的目录(在磁盘上)。
Next, open the .proj file in notepad and find http://localhost/someDirectory
; 接下来,在记事本中打开.proj文件,找到
http://localhost/someDirectory
; change it to http://localhost
. 将其更改为
http://localhost
。
Now, go in to your IIS settings and change the home directory of your web site to the directory where the web site is built on the disk. 现在,进入IIS设置并将网站的主目录更改为磁盘上构建网站的目录。
Finally, open the project in Visual Studio again. 最后,再次在Visual Studio中打开该项目。 Go to the web settings tab of the project properties and see that it is set to use the virtual directory
http://localhost/
. 转到项目属性的Web设置选项卡,看到它已设置为使用虚拟目录
http://localhost/
。
To set your root directory go into IIS and right click the "Default Web Site" go to properties --> "Home Directory" and set "Local Path" to the directory of your root website. 要设置根目录进入IIS并右键单击“默认网站”,转到属性 - > “主目录” ,并将“本地路径”设置为根网站的目录。 Then whenever you type http://localhost/ it will point to that website.
然后,无论何时键入http:// localhost /,它都将指向该网站。
I'm unsure about how this will effect your other sites though. 我不确定这将如何影响你的其他网站。
Let me know if this works. 让我知道这个是否奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.