问题
I have a multi-tenant application that is accessed in production as customer.ourdomain.com. For local development with IIS, we use a custom wildcard domain, company-localdev.com.
With IIS, this works without any particular configuration. IIS Express, on the other hand, only binds to localhost.
We have an ongoing migration project to ASP.NET 5, and we'd like to use IIS Express for an easier developer experience.
Is it possible to have IIS Express listen to *.company-localdev.com:1234? Bonus points if this can be automated so a developer can have it working just by opening the solution in IIS.
回答1:
In ASP.NET 5 / vNext, the config file is found in
~ProjectFolder~/.vs/config/applicationhost.config
From there, you can add new bindings like rdans explained.
回答2:
Ok I got it working on my local machine, here are all the steps I had to take:
Go to
{YourProjectFolder}\.vs\configand edit the applicationhost.config file:<site name="MySite" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="{MyProjectFolderPath}" /> </application> <bindings> <binding protocol="http" bindingInformation="*:49861:localhost" /> <binding protocol="http" bindingInformation="*:80:example.com" /> <!-- for subdomain testing only --> <binding protocol="http" bindingInformation="*:80:sub1.example.com" /> <binding protocol="http" bindingInformation="*:80:sub2.example.com" /> </bindings> </site>Run Notepad as Administrator and go to
C:\Windows\System32\drivers\etcto open the hosts file and amend it like so127.0.0.1 example.com127.0.0.1 sub1.example.com127.0.0.1 sub2.example.comAdd the url reservation by running cmd.exe as Administrator and typing in the netsh http prompt (to get the
netsh http>prompt, you must typenetshfollowed by Enter, thenhttpfollowed byEnter):add urlacl url=http://example.com:80/ user=everyoneadd urlacl url=http://sub1.example.com:80/ user=everyoneadd urlacl url=http://sub2.example.com:80/ user=everyone
Bear in mind that the keyword everyone depends on the language of your Windows OS. On a French OS, user=everyone shall be replaced by user="Tout le monde", on a German OS it should be user=jeder, in Spanish user=todos etc... you get the idea.
- Then after that you should be able to start debugging and navigate to the domain you have setup to see your website.
Hope this helps.
回答3:
Havent tried it with vs2015 but this works with iis express in vs 2012.
go to your documents folder. Open up IISExpress/config.applicationhost.config.
search for the 'sites' xml tag and find your site. You can modify your site bindings from here like so:
<bindings>
<binding protocol="http" bindingInformation="*:1234:company-localdev.com" />
</bindings>
Debugging only works for me if I run visual studio as an administrator.
来源:https://stackoverflow.com/questions/30242593/wildcard-hostname-in-iis-express-vs-2015