Using Custom Domains With IIS Express In Asp.Net Core
2018-02-11 12:03
567 查看
IIS Express是一个Mini版的IIS,能够支持所有的Web开发任务,但是这种设计有一些缺陷,例如只能通过localhost:<port>的方式来访问我们的应用程序,看起来就有点不爽,幸运的是我们可以更改默认的配置,使用自定义主机名来访问运行在IIS Express上的站点程序。
1、新建一个ASP.NET Core Web Application
如果不做任何修改的话,第一次运行会使用localhost:<port>的方式来运行,同时会在.vs文件夹下依次创建config文件夹,在config文件夹下生成一个applicationhost.config,这个配置文件就是IIS Express的启动配置文件。note:.vs文件夹默认是隐藏的,你需要将它显示出来。
2、在项目上右键→属性,选择调试选项,修改应用URL
也可以直接在launchSettings.json文件中进行修改
修改完成以后我们回到IIS Express的启动配置文件applicationhost.config,会发现自动多了一条binding节点
3、修改hosts文件,位于C:\Windows\System32\drivers\etc\hosts,用管理员身份打开它,并添加以下内容
再次运行程序
对于传统的ASP.NET 项目
很奇怪的是保存以后并不会再IIS Express配置文件中自动添加添加binding节点,需要我们手动去添加。
不管是新一代ASP.NET Core 还是 传统的ASP.NET 都是可以在IIS Express中自定义域名来访问,这样看起来是不是很酸爽呢?
1、新建一个ASP.NET Core Web Application
如果不做任何修改的话,第一次运行会使用localhost:<port>的方式来运行,同时会在.vs文件夹下依次创建config文件夹,在config文件夹下生成一个applicationhost.config,这个配置文件就是IIS Express的启动配置文件。note:.vs文件夹默认是隐藏的,你需要将它显示出来。
2、在项目上右键→属性,选择调试选项,修改应用URL
也可以直接在launchSettings.json文件中进行修改
修改完成以后我们回到IIS Express的启动配置文件applicationhost.config,会发现自动多了一条binding节点
3、修改hosts文件,位于C:\Windows\System32\drivers\etc\hosts,用管理员身份打开它,并添加以下内容
127.0.0.1 www.oneaspnet.dev
再次运行程序
对于传统的ASP.NET 项目
很奇怪的是保存以后并不会再IIS Express配置文件中自动添加添加binding节点,需要我们手动去添加。
不管是新一代ASP.NET Core 还是 传统的ASP.NET 都是可以在IIS Express中自定义域名来访问,这样看起来是不是很酸爽呢?
相关文章推荐
- Exception handling with custom error pages in ASP.NET using C#.
- [译]Writing Custom Middleware in ASP.NET Core 1.0
- [转]Create Custom Exception Filter in ASP.NET Core
- HTTP Error 502.5 - Process Failure asp.net core error in IIS
- [转]Writing Custom Middleware in ASP.NET Core 1.0
- Using jQuery with the ASP.NET CustomValidator Control(转)
- ASP.NET Core Logging in Elasticsearch with Kibana
- using MySQL 5 with ObjectDataSources in ASP.NET 2.0
- [转]HTTP Error 502.5 - Process Failure asp.net core error in IIS
- [转]Using NLog for ASP.NET Core to write custom information to the database
- How to integrate custom security policy with Windows domain authentication in ASP.NET
- [转]How do you create a custom AuthorizeAttribute in ASP.NET Core?
- Using MongoDB with Web API and ASP.NET Core
- Part 3 - Using custom view engines with asp.net mvc
- [导入]using MySQL 5 with ObjectDataSources in ASP.NET 2.0
- Using ASP.NET MVC with Different Versions of IIS
- Using IIS Express as ASP.NET Development Server
- [转]Publishing and Running ASP.NET Core Applications with IIS
- Working with Data in ASP.NET 2.0 :: Using TemplateFields in the GridView Control
- [转]An introduction to OAuth 2.0 using Facebook in ASP.NET Core