Setting IIS Application VirtualDirectory physicalpath - iis

I have a .bat file with the following line that runs appcmd to install the sites contained in sites.xml
%windir%\system32\inetsrv\appcmd add site /in < .\sites.xml
sites.xml contains the following
<?xml version="1.0" encoding="UTF-8"?>
<appcmd>
<SITE SITE.NAME="Default Web Site" SITE.ID="1" bindings="http/*:80:,net.tcp/808:*,net.pipe/*,net.msmq/localhost,msmq.formatname/localhost,https/*:443:" state="Started">
<site name="Default Web Site" id="1" serverAutoStart="true">
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
<binding protocol="net.tcp" bindingInformation="808:*" />
<binding protocol="net.pipe" bindingInformation="*" />
<binding protocol="net.msmq" bindingInformation="localhost" />
<binding protocol="msmq.formatname" bindingInformation="localhost" />
<binding protocol="https" bindingInformation="*:443:" />
</bindings>
<limits />
<logFile />
<traceFailedRequestsLogging />
<applicationDefaults />
<virtualDirectoryDefaults />
<application path="/">
<virtualDirectoryDefaults />
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot" />
</application>
<application path="/MyWebsite" applicationPool="MyWebsite">
<virtualDirectoryDefaults />
<virtualDirectory path="/" physicalPath="D:\Projects\MySolution\DEV\Source\MyWebsite" />
</application>
</site>
</SITE>
</appcmd>
I need to make part of the virtualdirectory physicalpath D:\Projects\MySolution be whatever the currentdirectory is.
Is there any variable that I can insert in sites.xml to make that happen?

Related

Getting 413 Payload too large then 500 System.ServiceModel.ServiceActivationException when i increase maxReceivedMessage in my WCF sharepoint app

I developed a wcf webservice in a sharepoint 2016 on premise environment.
When I try to upload a long body I used to get a 413 payload too large error so I changed my app.config to this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ilem.Sharepoint.WebServices.ISAPI.ilemGroupWS.Service">
<endpoint address="" binding="basicHttpBinding" contract="ilem.Sharepoint.WebServices.ISAPI.ilemGroupmWS.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/ilem.Sharepoint.WebServices.ISAPI.ilemGroup/Service/" />
</baseAddresses>
</host>
</service>
</services>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name=""
helpEnabled="true"
automaticFormatSelectionEnabled="true"
maxReceivedMessageSize="2147000000"
/>
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<basicHttpBinding>
<binding name="MyBinding" maxBufferPoolSize="2000000000"
maxBufferSize="2000000000" maxReceivedMessageSize="2000000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
<basicHttpsBinding>
<binding name="MyBinding" maxBufferPoolSize="2000000000"
maxBufferSize="2000000000" maxReceivedMessageSize="2000000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpsBinding>
</bindings>
</system.serviceModel>
</configuration>
But now I get this error: 500 (System.ServiceModel.ServiceActivationException)
Is there any way to resolve this issue?
I found that behaviorConfiguration, bindingConfiguration, <security mode="Transport"> are not set in your code, please make sure to configure them.
You can try setting includeExceptionDetailInFaults to true or configuring tracing to get error details.

Multiple sites in Azure web app

My Azure web app (example.azurewebsites.net) has one custom domain, applicationhost.config:
<sites>
<site name="example" id="111111111">
<bindings>
<binding protocol="http" bindingInformation="*:80:customdomain.com" />
<binding protocol="https" bindingInformation="*:443:customdomain.com" />
<binding protocol="http" bindingInformation="*:80:example.azurewebsites.net" />
<binding protocol="https" bindingInformation="*:443:example.azurewebsites.net" />
</bindings>
<application path="/" applicationPool="example" preloadEnabled="true">
<virtualDirectory path="/" physicalPath="D:\home\site\wwwroot" />
<virtualDirectory path="/iisnodedebugger" physicalPath="C:\DWASFiles\Sites\example\Temp\iisnode" />
</application>
<traceFailedRequestsLogging enabled="false" customActionsEnabled="true" directory="D:\home\LogFiles" />
<detailedErrorLogging enabled="true" directory="D:\home\LogFiles\DetailedErrors" />
<logFile logSiteId="false" />
</site>
...
</sites>
The custom domain's bindigs are automatically added to the default site (example).
I would like to change it, i would like to create a new site with bindings to the custom domain (customdomain.com).
applicationHost.xdt (created with IIS Manager):
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.applicationHost>
<sites>
<site name="example" xdt:Locator="Match(name)">
<bindings>
<binding bindingInformation="*:443:customdomain.com" xdt:Locator="Match(bindingInformation)" xdt:Transform="Remove" />
<binding bindingInformation="*:80:customdomain.com" xdt:Locator="Match(bindingInformation)" xdt:Transform="Remove" />
</bindings>
</site>
<site name="customdomain" id="222222222" xdt:Transform="InsertAfter(/configuration/system.applicationHost/sites/site[(#name='example')])">
<bindings>
<binding protocol="http" bindingInformation="*:80:customdomain.com" />
<binding protocol="https" bindingInformation="*:443:customdomain.com" />
</bindings>
<application path="/" applicationPool="example" preloadEnabled="true">
<virtualDirectory path="/" physicalPath="D:\home\site\wwwroot2" />
<virtualDirectory path="/iisnodedebugger" physicalPath="C:\DWASFiles\Sites\example\Temp\iisnode" />
</application>
</site>
</sites>
</system.applicationHost>
</configuration>
After restart the transform is successfull.
The problem: it has no effect. The customdomain.com is still served from "D:\home\site\wwwroot" and not "D:\home\site\wwwroot2".
After that i deleted only the bindigs without adding the new site, customdomain still working... After that i deleted the whole site (example), example.azurewebsites.net and customdomain.com still working.
Where am I mistaken? Isn't it possible to manipulate the sites section?
May i ask why are you trying to make your life hard?
Why don't you deploy your 2nd application to a new Web App? You can share the same App Service Plan (same VM) if cost is the essence here.
Every Web App has its own custom domain settings which you can configure visually through the Portal:
https://azure.microsoft.com/en-gb/documentation/articles/web-sites-custom-domain-name/
i did this in the webconfig and it seems to work:
**<rule name="REDIRECT To Site Within a Site" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}"pattern="^www\.SiteWithinSiteName\.com$" />
<add input="{PATH_INFO}" pattern="^/path/SiteWithinSiteRoot/" negate="true" />
</conditions>
<action type="Rewrite" url="\path\SiteWithinSiteRoot\{R:0}" />
</rule>**

The XML specification is not valid:

The XML specification is not valid: The element 'WebRole' in namespace 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition' has incomplete content. List of possible elements expected: 'Sites' in namespace 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition'.
Here is the XML file
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureCloudService1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="Web" vmsize="Small">
<Startup>
<Task commandLine="StartUp.cmd" executionContext="elevated" taskType="background" />
</Startup>
</WebRole>
</ServiceDefinition>
As the error says.... Your <WebRole> tag must include a <Sites> node.
When you create a Azure Cloud Service project, there will be a default ServiceDefinition.csdef in Solution Explorer with the content below,
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureCloudService1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="WebRole1" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
<Setting name="StorageConnectionString" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
</WebRole>
<WorkerRole name="WorkerRole1" vmsize="Small">
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
</ConfigurationSettings>
</WorkerRole>
</ServiceDefinition>
So, you are missing a <Sites> node.

DevFabric equivalent of ApplicaiontHosts.config?

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>

IIS 7.5 Express New Virtual Dir

how do i add new virtual directory?
I'm getting error (The type or namespace name 'xxx' could not be found) but the files are all in /bin.
i have tried editing the applicationhost.config like this:
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/" applicationPool="Clr2IntegratedAppPool">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
<virtualDirectory path="/SubFolderApp" physicalPath="%IIS_SITES_HOME%\WebSite1\SubFolderApp" allowSubDirConfig="true" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":80:localhost" />
</bindings>
</site>
You need to create a child application. Your configuration created child virtual directory. The configuration below turns /SubFolderApp into an application.
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/" applicationPool="Clr2IntegratedAppPool">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<application path="="/SubFolderApp" applicationPool="Clr2IntegratedAppPool">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1\SubFolderApp" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":80:localhost" />
</bindings>
</site>

Resources