IIS7 Expressでカスタムホストヘッダー /バインディングを使用することは可能ですか?
-
26-10-2019 - |
質問
新しいものを構成しようとしています ASP.NET MVC3 使用 IIS7 Express (私のローカル開発機で)を使用する カスタムドメイン名.
例えば。
- 私の地元の開発機。
- 私のウェブブラウザを開きます
- goto http://dev.www.mydomain.com
- 私のVisual Studio MVCプロジェクトが始まります
ホストファイルをハッキングして含めるように(はい、ファイルを保存しました。
127.0.0.1 dev.www.mydomain.com
IIS7 Expressを使用してこれを行うように構成する方法を理解できません。
私は行きました MVC Project => Properties => Web
そして、次のことをしました: -
その後、サイトを実行しようとしました...
誰かが助けることができますか?
解決
実行中の場合は現在実行されています
開ける
%userprofile%\documents\iisexpress\config\applicationhost.config
vs2015+の場合:$(solutionDir)\.vs\config\applicationhost.config
興味のあるサイトを見つけてください。
<binding protocol="http" bindingInformation="*:<your-port-number>:localhost" />
同様のエントリを追加します
<binding protocol="http" bindingInformation="*:<your-port>:dev.www.mydomain.com" />
上記のBindigエントリのすぐ下。もう一度サイトを実行します
注:非ローカルホストバインディングには管理者の特権が必要なため、管理者としてVisual Studioを開始する必要があります
純粋なクロームによる更新:
これに加えて、以下を行う必要があります。これらのコメントは私のweb.configの上部にあります(他のいくつかのものと一緒に...)。
1) netsh http add urlacl url=http://localhost.www.foo.com:80/ user=everyone
netsh http add urlacl url=http://localhost.foo.com:80/ user=everyone
netsh http add urlacl url=http://localhost.foobar.com.au:80/ user=everyone
netsh http add urlacl url=http://localhost.pewpew.com:80/ user=everyone
... etc ...
NOTE: to remove a urlacl: netsh http delete urlacl url=<url in here> .. eg http://foo.com:80
2) ... and we need to edit the main IIS7 express config file to define the url's which will be accepted, per web -site-
File: C:\Users\<UserName>\Documents\IISExpress\config\applicationhost.config
<bindings>
<binding protocol="http" bindingInformation="*:1200:localhost" />
<binding protocol="http" bindingInformation="*:80:localhost.www.foo.com" />
<binding protocol="http" bindingInformation="*:80:localhost.foo.com" />
<binding protocol="http" bindingInformation="*:80:localhost.foobar.com.au" />
<binding protocol="http" bindingInformation="*:80:localhost.pewpew.com" />
</bindings>
他のヒント
上記と同様のIIS7バウンドサイトのデバッグを達成することに成功しました。欠けているように見える唯一のステップは、プロジェクト内です。
- プロジェクト] => [プロジェクト]メニューから[プロジェクト]プロパティを選択します
- Web]セクションをクリックします
- 「使用」を選択します カスタム Webサーバー "オプション、およびサーバーURLを「http://dev.www.my-domain.com」に設定します