I'm using appcmd to create a new virtual directory in IIS8. The syntax for this is:
appcmd add vdir /app.name:<NAME> /path:<PATH> /physicalPath:<PHYSICAL-PATH>
This works fine. Now I need to set some credentials; this is easy in the GUI (virtual dir > basic settings > connect as). When I set this, I can see in my applicationHost.config file that it is updating an XML entry. So I should be able to set that manually with appcmd. I'm struggling with the syntax to navigate to the right XML element so I can set the attribute userName and add the attribute password.
Here is my XML:
<sites>
<site name="EXAMPLESITE" id="4">
<application path="/" applicationPool="EXAMPLEPOOL">
<virtualDirectory path="/" physicalPath="c:\wwwroot\" userName="" />
<virtualDirectory path="/upload" physicalPath="\\SOME-COMPUTER-ON-NETWORK\upload" userName="" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80" />
</bindings>
</site>
</sites>
This should work:
appcmd set vdir /vdir.name:"EXAMPLESITE/upload" /userName:user /password:password
Related
I have an installation of IIS Express 10 on my local machine that I use for developing MVC applications. Normally, I use the following configuration in applicationhost.config for my sites, where I have no virtual directories defined:
<site name="Development Web Site" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\dev\MyMVC" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
Using the above configuration, the MVC application can be accessed with no errors at http://localhost:8080
However, I recently tried to make the application accessible using a virtual directory (please note the path "C:\fake" as the root directory--IIS requires a site's root directory to be defined before any virtual directories are--see How to configure a different virtual directory for web site project with Visual Studio 2015). I created the virtual directory using the following configuration in applicationhost.config:
<site name="Development Web Site" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\fake" />
</application>
<application path="/test/app">
<virtualDirectory path="/" physicalPath="C:\dev\MyMVC" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
Using the above configuration and navigating to http://localhost:8080/test/app, the MVC application begins to load, but I get the following error:
c:\dev\MyMVC\views\index.cshtml(14): error CS0103: The name 'ViewBag' does not exist in the current context
What is the virtual directory configuration doing to cause this error? It works fine without the virtual directory.
You can replicate this error using a fresh MVC template in Visual Studio, without touching any code other than what's in the applicationhost.config file, so I don't think the problem is in my code.
It turned out, that not only does IIS Express require a root directory for the site as a whole to be defined, but also every virtual directory URL segment as well. So, it worked after changing the configuration to this (note the intermediate "/test" virtual directory):
<site name="Development Web Site" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\fake" />
</application>
<application path="/test">
<virtualDirectory path="/" physicalPath="C:\fake" />
</application>
<application path="/test/app">
<virtualDirectory path="/" physicalPath="C:\dev\MyMVC" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
http://localhost:8080/test/app now works properly without the 'ViewBag' error
This Is my Host file
192.168.1.15:33693 stackoverflow.com
192.168.1.15 stackoverflow.com
first line i get nothing
second line i get iis page
i want to get my site buy it does not working
this is my applicationhost.config File
<site name="stackoverflow" id="14">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\stackoverflow\Desktop\stackoverflow\stackoverflow" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:33693:localhost" />
<binding protocol="http" bindingInformation="*:33693:192.168.1.15" />
</bindings>
</site>
Using the IIS manager, define a binding like so:
Equivalently, you can add the following binding statement in applicationhost.config:
<binding protocol="http" bindingInformation="*:80:stackoverflow.com" />
Additionally, 192.168.1.15 needs to be the IP of your machine. Using 127.0.0.1 is usually a better option to use in the host file in case your IP is assigned by DHCP.
I can connect to my Web API app from a browser or from another app (such as a Windows Forms app) by going to:
http://localhost:28642/api/inventoryitems/GetAll
...but how can I make localhost available to others (on the same network) so that they can make these same REST calls?
Is it just a matter of them connecting to my machine, like so:
http://platypus:28642/api/inventoryitems/GetAll
...and if so, what do I have to do to make it accessible (if anything)?
At any rate, I don't really want to have to run my Web API app all the time on my machine, so: How can I set it up so that it will run 24/7 without my having to start/babysit it?
Would an Azure web site be a valid option for this?
UPDATE
It could be (based on what I read here) that changing applicationhost.config from this:
<site name="HandheldServer" id="20">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\HandheldServer\HandheldServer" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:28642:localhost" />
<binding protocol="http" bindingInformation="*:28642:platypus" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>
</site>
...to this:
<site name="HandheldServer" id="20">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\HandheldServer\HandheldServer" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:28642:localhost" />
<binding protocol="http" bindingInformation="*:28642:platypus" />
<binding protocol="http" bindingInformation="*:28642:" />
<binding protocol="http" bindingInformation=":28642:" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>
</site>
...will make it available (but, will I have to be running it, or will IISExpress fire it up in the background?)
Presumably, the first entry may already make it available. I don't know if the prepended * is necessary, so I have an entry both with and without that.
You have the choice :
buy a Rasperberry Pi in order to have an independant server/service running instead of your machine
buy a VPS
open the firewall ports on your router
use your smartphone (yes it's possible)
change your hosts file (windows, linux, mac)
there is no miracle ;)
I am testing OAuth with local application hosted on dev fabric.
I want to bind a particular hostname to my local application, usually on IISExpress I would edit the following element in ApplicaiontHosts.config
<site name="BasicChat" id="15">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\xxx.yyy_VAIO\Downloads\Samples-master\Samples-master\BasicChat" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:44914:localhost" />
</bindings>
</site>
What would be the equivalent when I'm testing on DevFabric? How can I alias the call to localhost?
In the ServiceDefinition.csdef.
Add the hostheader attribute eg:
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="xxx" hostHeader="my.yyy.com" />
</Bindings>
I have a website working fine on IIS express until I wanted to add a second one and have them both run off the same port number. Now I can't figure out how to get the path right. When I browse to the site after running iIS express it complains of a error:
Unrecognized configuration path 'MACHINE/WEBROOT/APPHOST/RISWEB'
and IIS Express returns error 500.19
Here is my config. When I set the path to be "/" it works, but when its something else it does not. I would like to browse to http:// c65273/risweb and have my website show up.
<site name="RISWEB" id="1834812154">
<application path="/risweb" applicationPool="ConnectPool">
<virtualDirectory path="/risweb" physicalPath="C:\c2010\risweb\RISWEB" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:c65273" />
</bindings>
</site>
I hit a similar problem and was able to resolve it by doing the following:
Remove the configuration section for the site from my applicationhost.config
In Visual Studio go to the Project Properties > Web tab and then click Create Virtual Directory to have VS recreate the configuration section.
It then worked fine, the resulting configuration section will look something like this:
<site name="WebDemos-Site" id="5">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\rvesse\Documents\My Web Sites\WebDemos-Site" />
</application>
<application path="/demos">
<virtualDirectory path="/" physicalPath="C:\Users\rvesse\Documents\mercurial\dotnetrdf\Samples\WebDemos" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:64132:localhost" />
</bindings>
</site>
Note that VS generates an empty website for the root directory of the site