简体   繁体   English

在IIS express中使用自定义域而不是localhost:*

[英]using custom domain instead of localhost:* in IIS express

I have created an MVC4 web application and I want to use my custom domain myApp.com instead of localHost:56605 . 我创建了一个MVC4 Web应用程序,我想使用我的自定义域myApp.com而不是localHost:56605。 so I have added 所以我补充说

127.0.0.1:56605  myApp.com

to the hosts file. 到hosts文件。 2nd: I have gone to project properties in Visual studio 2012 and added myApp.com instead of localhost:56605. 第二:我去了Visual Studio 2012中的项目属性并添加了myApp.com而不是localhost:56605。 but when I click on Create virtual directory I got a warning indicating unable to create a virtual directory. 但是当我点击Create virtual directory时,我收到一条警告,指示无法创建虚拟目录。 I also edited the applicationHost.config file too. 我也编辑了applicationHost.config文件。 but the problem still remains. 但问题仍然存在。

I have also searched in stackoverflow but most rely to this approach myapp:56605. 我也在stackoverflow中搜索,但大多数依赖于这种方法myapp:56605。 I dont want to insert port number in the url. 我不想在网址中插入端口号。

how can I accomplish this? 我怎么能做到这一点?

so what I did to fix this issue: 所以我做了什么来解决这个问题:

in the hosts file I added: 在hosts文件中我添加了:

127.0.0.1 myApp.com

then in the applicationhost.config which is located in IISExpress in my document I edited binding section of my app like this: 然后在我的文档中的IISExpress中的applicationhost.config ,我编辑了我的应用程序的绑定部分,如下所示:

<binding protocol="http" bindingInformation="*:80:myApp.com" />
<binding protocol="https" bindingInformation="*:443:myApp.com" />

then go to project properties in visual studio and in the web tab edite project url like this: 然后转到visual studio中的项目属性和web选项卡edite项目URL,如下所示:

http://myapp.com http://myapp.com

then click on create virtual directory, your virtual directory will created successfully. 然后单击创建虚拟目录,您的虚拟目录将成功创建。 then your site using port 80. which shouldn't used by any other app in your pc. 然后您的网站使用端口80.您的电脑中的任何其他应用程序不应使用它。 else you get an error indicating your port 80 is used by another process. 否则你会收到一个错误,表明你的端口80被另一个进程使用。

to fix this issue close skype, teamViewer, and in IIS manager all of the site you have created and using port 80 should be stopped. 解决此问题关闭skype,teamViewer,并在IIS管理器中,您已创建并使用端口80的所有站点都应停止。

finally you can successfully surf your site www.myApp.com more explanation: 最后,您可以成功浏览您的网站www.myApp.com更多解释:

http://www.macaw.nl/weblog/2013/6/configuring-an-asp-net-project-for-development-with-ssl http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx http://www.macaw.nl/weblog/2013/6/configuring-an-asp-net-project-for-development-with-ssl http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx

but when I click on Create virtual directory I got a warning indicating unable to create a virtual directory 但是当我点击Create virtual directory时,我收到一条警告,指示无法创建虚拟目录

-> this can be fixed if you run visual studio as an administrator - >如果您以管理员身份运行visual studio,则可以修复此问题

I found a faster way. 我发现了一种更快的方法。 Change the applicationhost.config where you put localhost over ip directly (127.0.0.1). 更改applicationhost.config,直接将localhost放在ip上(127.0.0.1)。

<binding protocol="http" bindingInformation="*:55449:127.0.0.1" />

In the file hosts in system32 add the name of the domain: 在system32中的文件主机中添加域名:

127.0.0.1 domainname.com

So you can access by name your application running on iis express. 因此,您可以通过名称访问在iis express上运行的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM