如何在同一个 IIS Express 实例上提供两个 ASP.Net MVC 应用程序?

发布于 2024-11-04 00:38:13 字数 1435 浏览 2 评论 0原文

我有两个 ASP.Net MVC 应用程序,例如 Site1Site2

现在,我可以通过访问 http://localhost/ 成功访问 Site1

这是我的 IIS Express applicationhost.config 文件:

<sites>
   <site name="Site1" id="1" serverAutoStart="true">
       <application path="/">
           <virtualDirectory path="/" physicalPath="%IIS_USER_HOME%\wwwroot\Site1" />
       </application>
       <bindings>
           <binding protocol="http" bindingInformation=":80:localhost" />
           <binding protocol="http" bindingInformation=":80:10.49.0.137" />
       </bindings>
   </site>
   <siteDefaults>
       <logFile logFormat="W3C" directory="%IIS_USER_HOME%\logs" />
       <traceFailedRequestsLogging directory="%IIS_USER_HOME%\logs\tracelogfiles" enabled="false" maxLogFileSizeKB="1024" />
   </siteDefaults>
   <applicationDefaults applicationPool="IISExpressAppPool" />
   <virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>

我现在想要什么是:

  • http://localhost/Site1 上访问 Site1
  • Site2 放在 %IIS_USER_HOME%\wwwroot\Site2
  • http.//localhost/Site2 上访问 Site2

我应该如何更改上面的 applicationhost.config 来实现我想要的?

谢谢。

I have two ASP.Net MVC applications, let's say Site1 and Site2.

For now, I can successfully access Site1 by visiting http://localhost/

Here's my IIS Express applicationhost.config file:

<sites>
   <site name="Site1" id="1" serverAutoStart="true">
       <application path="/">
           <virtualDirectory path="/" physicalPath="%IIS_USER_HOME%\wwwroot\Site1" />
       </application>
       <bindings>
           <binding protocol="http" bindingInformation=":80:localhost" />
           <binding protocol="http" bindingInformation=":80:10.49.0.137" />
       </bindings>
   </site>
   <siteDefaults>
       <logFile logFormat="W3C" directory="%IIS_USER_HOME%\logs" />
       <traceFailedRequestsLogging directory="%IIS_USER_HOME%\logs\tracelogfiles" enabled="false" maxLogFileSizeKB="1024" />
   </siteDefaults>
   <applicationDefaults applicationPool="IISExpressAppPool" />
   <virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>

What I want now is:

  • Access Site1 on http://localhost/Site1
  • Place Site2 on %IIS_USER_HOME%\wwwroot\Site2
  • Access Site2 on http.//localhost/Site2

How should I change the above applicationhost.config to achieve what I want?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少女净妖师 2024-11-11 00:38:13

如下所示更改 applicationhost.config 并重新启动 IIS Express。

<sites>    
  <site name="Site1" id="1" serverAutoStart="true">
   <application path="/">            
      <virtualDirectory path="/" physicalPath="%IIS_USER_HOME%\wwwroot\" />
   </application>        
   <application path="/site1">            
      <virtualDirectory path="/" physicalPath="%IIS_USER_HOME%\wwwroot\Site1" />
   </application>        
   <application path="/site2">            
      <virtualDirectory path="/" physicalPath="%IIS_USER_HOME%\wwwroot\Site2" />
   </application>        
   <bindings>            
     <binding protocol="http" bindingInformation=":80:localhost" />            
     <binding protocol="http" bindingInformation=":80:10.49.0.137" />        
   </bindings>    
  </site>    
  <siteDefaults>        
    <logFile logFormat="W3C" directory="%IIS_USER_HOME%\logs" />        
    <traceFailedRequestsLogging directory="%IIS_USER_HOME%\logs\tracelogfiles" enabled="false" maxLogFileSizeKB="1024" />    
  </siteDefaults>    
  <applicationDefaults applicationPool="IISExpressAppPool" />    
  <virtualDirectoryDefaults allowSubDirConfig="true" /> 
</sites>

change your applicationhost.config as shown below and restart IIS Express.

<sites>    
  <site name="Site1" id="1" serverAutoStart="true">
   <application path="/">            
      <virtualDirectory path="/" physicalPath="%IIS_USER_HOME%\wwwroot\" />
   </application>        
   <application path="/site1">            
      <virtualDirectory path="/" physicalPath="%IIS_USER_HOME%\wwwroot\Site1" />
   </application>        
   <application path="/site2">            
      <virtualDirectory path="/" physicalPath="%IIS_USER_HOME%\wwwroot\Site2" />
   </application>        
   <bindings>            
     <binding protocol="http" bindingInformation=":80:localhost" />            
     <binding protocol="http" bindingInformation=":80:10.49.0.137" />        
   </bindings>    
  </site>    
  <siteDefaults>        
    <logFile logFormat="W3C" directory="%IIS_USER_HOME%\logs" />        
    <traceFailedRequestsLogging directory="%IIS_USER_HOME%\logs\tracelogfiles" enabled="false" maxLogFileSizeKB="1024" />    
  </siteDefaults>    
  <applicationDefaults applicationPool="IISExpressAppPool" />    
  <virtualDirectoryDefaults allowSubDirConfig="true" /> 
</sites>
情释 2024-11-11 00:38:13

检查这个很棒的条目。

在开发时使用 SSL使用 IISExpress 更容易 - Scott Hanselman

在 applicationHost.config 追加绑定后执行 netsh 命令。

netsh http add urlacl url=http://10.49.0.137:80/ user=everyone

Check this great entry.

Working with SSL at Development Time is easier with IISExpress - Scott Hanselman

Execute netsh command after applicationHost.config append binding.

netsh http add urlacl url=http://10.49.0.137:80/ user=everyone
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文