Anyway .. I started building my Web Applications using PowerShell using a very handy TechNet article (http://technet.microsoft.com/en-us/library/ee806885.aspx). This describes "Create a Web application that uses Windows-claims authentication" which is required for SharePoint 2013 because "classic" (i.e. non-claims) web applications are deprecated and should not be used anymore.
Unfortunately this has a rather glaring bug. You see the PowerShell command that it tells you to use is:
$ap = New-SPAuthenticationProvider
$wa = New-SPWebApplication -Name <ClaimsWindowsWebApplication> -ApplicationPool <ClaimsApplicationPool> -ApplicationPoolAccount <ClaimsApplicationPoolAccount> -URL <URL> -Port <Port> -AuthenticationProvider $apUnfortunately there are two of the commands missing ... but how did I find this out (because the first time you run it .. it works!)
I basically tried to create a SharePoint 2013 Web Application using the command above. The URL was going to be http://test and I was running it on Port 80 (standard for non SSL traffic). The Web Application created fine, but I was getting 404 errors trying to access it. I tried to create another web application (thinking something went wrong) and I got the following error message:
New-SPWebApplication : The IIS Web Site you have selected is in use by SharePoint. You must select another port or hostname.
PowerShell Error message when creating a second Web Application |
IIS Site created without any Host Name bindings |
IIS Virtual Directory created using Port Number (80) |
HostHeader Specifies a valid URL assigned to the Web application that must correlate to the alternate access mapping configuration, in the form server_name. (If no value is specified, the value is left blank)
Path Specifies the physical directory for the new Web application in the virtual directories folder (If no value is specified, the value %wwwroot%\wss\VirtualDirectories\<portnumber> is applied)
So without a HostHeader value the IIS Binding information had been missed out. And without a Path specified it had used the port number (80) for the IIS folder. This technically "worked" as far as the script goes, but when I tried to create my second web application it was trying to use the same (blank) host header and the same folder name (80) which .. of course .. "is in use by SharePoint" already.
I added these two additional parameters to my script .. and voila! Everything started working. The full command (at a minimum) should therefore be:
$ap = New-SPAuthenticationProvider
$wa = New-SPWebApplication -Name <ClaimsWindowsWebApplication> -ApplicationPool <ClaimsApplicationPool> -ApplicationPoolAccount <ClaimsApplicationPoolAccount> -URL <URL> -Port <Port> -HostHeader <HostHeader> -Path <IISFolderName> -AuthenticationProvider $apI deleted the old (80) web app and recreated it with a proper path and now everything appears to be back to normal.
Using SharePoint 2010, your people can set up Web sites to share information with others, manage documents from start to finish, and publish reports to help everyone make better decisions.Its good to see your websites and your detail.
ReplyDeleteThanks a really useful tip. I noticed that my host named web app did have he /80 dir where as the host header web apps do have the default dir based on the host header and the port. Anyway, modified my script to add the iis path. I ran into an issue re url mapping to the web app being already in use. I restarted the timer job serve and re-run and everything ok
ReplyDelete