如何在IISExpress上使用带有localhost的子域? [英] How to use subdomains with localhost on IISExpress?

查看:180
本文介绍了如何在IISExpress上使用带有localhost的子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在通过localhost:5252本地服务我的MVC应用程序。

I'm serving my MVC app locally via localhost:5252 right now.

我正在尝试通过让localhost和contoso.localhost指向我的Web应用程序实例来设置我的应用程序来测试多租户。

I'm trying to set up my app to test multi-tenancy by having both localhost and contoso.localhost point to my web app instance.

我使用相应的条目设置我的主机文件:

I set up my hosts file with the corresponding entry:

127.0.0.1       contoso.localhost

但是我不知道还需要做些什么才能做到这一点工作。现在我在导航时只获得一个标准的IIS8页面,即使我在IIS管理器中没有做任何事情。

However I'm not sure what else I need to do to make this work. Right now I just get a standard IIS8 page when I navigate, even though I haven't done anything in IIS Manager.

我正在努力避免在本地使用IIS,因为一切都在使用IISExpress。有没有简单的方法来实现这个目标?

I'm trying to avoid having to use IIS locally, as everything is working with IISExpress. Is there any easy way to achieve this?

推荐答案

这可以通过编辑applicationHost.config文件来实现

This can be accomplished by editing the applicationHost.config file

C:\Users\yourProfile\Documents\IISExpress\config\applicationHost.config

Visual Studio通常会在您进行配置更改时为您编辑此文件,但您可以手动编辑。找到您正在使用的特定网站,以下绑定应该有效:

Visual Studio usually handles editing this file for you when you make configuration changes, but you can manually edit. Find the particular site you are working with and the following bindings should work:

<bindings>
   <binding protocol="http" bindingInformation="*:5252:localhost" />
   <binding protocol="http" bindingInformation="*:5252:contoso.localhost" />
</bindings>

您可以真正将端口更改为您想要的任何内容,这样您就可以使用80来节省一些打字。继续添加绑定以根据需要填写多租户。

You can really change the port to anything you want so you could use 80 to save yourself some typing. Continue adding bindings to fill out your multi-tenancy as needed.

如果您正在寻找更多信息,我建议您查看 Scott Hanselman关于IIS Express& amp; SSL。

If you are looking for more information, I would recommend checking out Scott Hanselman's blog post on IIS Express & SSL.

使用VS 2015&在.NET核心中,applicationHost.config已移至基于目录的系统,用于存储配置而不是全局配置文件。新位置与您的项目相关:

With VS 2015 & .NET core, the applicationHost.config has moved to a directory based system of storing the configuration instead of a global configuration file. The new location is relative to your project:

.vs\config\applicationHost.config

相同的编辑主体适用于此文件,但在使用TFS源代码控制时,VS 在分支之间进行更改时不会编辑文件,因为它与全局一样文件。

The same editing principals apply to this file, but when using TFS source control VS does not edit the file when changing between branches as it did with the global file.

关于域的通配符注释,通配符主机名。因此,它可能在IIS Express 10中受支持,但可能不在之前。

Regarding the wildcard comment for domains, wildcarding hostname isn't supported until IIS 10. Therefore, it may be supported in IIS Express 10, but probably not before.


bindingInformation 的细分是:

bindingInformation =< IPAddress>:< Port>:< Hostname>

这篇关于如何在IISExpress上使用带有localhost的子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆