You need to actually create a new record for each subdomain in the hosts file. You can't use wildcards.
127.0.0.1 domain.dev
127.0.0.1 foo.domain.dev
127.0.0.1 bar.domain.dev
Although it seems that it can be done with some extra work, see this question for more details.
You also need to include the port number when accessing the URL. The browser would point to http://foo.domain.dev:0000
, using the port number assigned in VS, of course.
If you are using the Visual Studio Development Server, that's all there is to it. If using IIS Express, it takes a bit more work.

Then you need to make sure you have a record in the IIS applicationhost.config file :
<site name="YourApplication" id="25">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Path\To\Your\App" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:2750:foo.domain.dev" />
</bindings>
</site>
Update
<site name="DomainProject" id="18">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\William\Source" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:32939:domain.dev" />
<binding protocol="http" bindingInformation="*:32939:domain2.dev" />
</bindings>
</site>