简体   繁体   English

如何使.net Web应用程序作为Visual Studio中的根应用程序运行

[英]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.

相关问题 如何在没有Visual Studio的情况下将ASP.NET Web应用程序项目作为虚拟主机运行? - How can I run ASP.NET Web Application project as a Virtual host , without Visual Studio? 如何制作可在任何系统上运行而无需Visual Studio的独立Visual Studio应用程序 - how to make standalone visual studio application which can run on any system without having visual studio Visual Studio 2022 - Visual Basic ASP.NET Web 应用程序 - Visual Studio 2022 - Visual Basic ASP.NET Web Application 如何在 Visual Studio 调试中以管理员身份运行应用程序? - How to run application as administrator in debug with Visual Studio? 如何在Visual Studio中组织.NET MVC应用程序 - How to organize a .NET MVC application in Visual Studio 如何让Visual Studio自动将其调试器附加到Web应用程序和Web服务? - How can I make Visual Studio automatically attach its debugger to both a web application and web service? 如何在Visual Studio 2012中的命令行上将ASP.NET网站或Web应用程序发布到文件系统 - How to publish an ASP.NET web site or web application to a file system on the command line in Visual Studio 2012 如何使用 ASP.NET 核心 web 应用程序托管 web 页面? - How can I host web pages with an ASP.NET Core web application - API project in Visual Studio? 网站无法在Visual Studio中运行,会停止应用程序池 - Web site won't run in Visual Studio, stops application pool 在Visual Studio中发布Web应用程序,然后在远程计算机上运行npm install - Publish a web application in visual studio and run npm install on the remote machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM