I have an asp.net mvc web page. I'm using config transforms with it. The config transform in the bin directory is correct. However, when I debug with IIS express, all the app settings being used are actually from the original web.config, not the transformed web.config in the bin folder. If I rename the web.config to something else in the root folder, debugging will halt as soon as it tries to read a connection string because it says it's not initialized. What is the problem?
Transformations only apply when you publish the project. However their is a hack to it
You can try using the below code. Your original configuration should be in Web.Base.Config
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets" />
<Target Name="BeforeBuild">
<TransformXml
Source="Web.Base.config"
Transform="Web.$(Configuration).config"
Destination="Web.config" />
</Target>
You can also refer to below URL as sometime it makes transformation twice and you need to add steps for beforebuild
https://sebnilsson.com/blog/asp-net-transform-web-config-with-debug-release-on-build/
Is there a way to rebuild the applicationHost.config file in IIS 7 with a Windows command? Or if you can help me fix the issue by modifying this file, that's fine too. When comparing this file to other servers, I'm noticing very important sections that are missing or different after deleting a site and a few application pools.
I am by no means an expert in IIS 7, but I've been using it for 7 years now. I am confident have performed all of the proper steps for a new site configuration and it still gives me this error, "401.1 "You are not authorized to view this page. You do not have permission to view this directory or page using the credentials that you supplied."
C:\Windows\System32\inetsrv\config\applicationHost.config
This happened on a machine where IIS APPPOOL{app pool user} doesn't exist, so we've never used this user, like I normally do when configuring permissions. We did however add proper permissions to IIS_IUSRS (with IUSR in this group) last week, and the site worked fine. We're using Windows Authentication, and all other authentication methods are turned off. No virtual directories. We are using .NET 4.0, Classic, and 32 bit app (under advanced settings).
We had to manually update the host name by doing the following command in "C:\Windows\System32\inetsrv" on the binding because IIS would grey out the host name when the VeriSign SSL certificate was added to the binding.
appcmd set site /site.name:"himc" /+bindings.[protocol='https',bindingInformation='*:443:subdomain.domain.com']
Missing sections on "bad" web server:
1 - exists on "good" box, missing on "bad" box
<customMetadata>
<key path="LM/W3SVC/INFO">
<property id="4012" dataType="String" userType="1" attributes="Inherit" value="NCSA Common Log File Format,Microsoft IIS Log File Format,W3C Extended Log File Format,ODBC Logging" />
<property id="2120" dataType="MultiSZ" userType="1" attributes="None" value="400,0,,,0
" />
</key>
</customMetadata>
2 - exists on "good" box, missing on "bad" box
<asp>
<cache diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled Templates" />
</asp>
3 - this section exists on the "good" box, but only 2.0 (first 2 lines) exist on the "bad" box.
<isapiFilters>
<filter name="ASP.Net_2.0.50727.0" path="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_filter.dll" enableCache="true" preCondition="bitness32,runtimeVersionv2.0" />
<filter name="ASP.Net_2.0.50727-64" path="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_filter.dll" enableCache="true" preCondition="bitness64,runtimeVersionv2.0" />
<filter name="ASP.Net_2.0_for_V1.1" path="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv1.1" />
<filter name="ASP.Net_4.0_64bit" path="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv4.0,bitness64" />
<filter name="ASP.Net_4.0_32bit" path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv4.0,bitness32" />
</isapiFilters>
4 - this section exists on "bad" box, but is missing on the "good" box
<applicationDependencies>
<application name="Active Server Pages" groupId="ASP" />
</applicationDependencies>
5 - ssiExecDisable property is missing on "good" box
<serverSideInclude ssiExecDisable="false" />
6 - section missing on "bad" box
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
Apparently, Microsoft keeps a history of these files in:
C:\inetpub\history\
Do a backup of all config files first!
So apparently, IIS keeps a history of the config files in C:\inetpub\history. So what you need to do is remember the last known date IIS worked fine and then copy the contents of the config file from c:\inetpub\history and replace config files in c:\windows\system32\inetsrv\config.
Good luck!
If you just want to modify currently active applicationHost.config take a look at this article:
Editing Applicationhost.config on 64 bit Win2008
As the article says, for some reason applicationHost.config is visible only using Explorer (which explains why I wasn't seeing file from my custom file manager) and you can edit it without problems using Notepad (again, any other editor and you'll run into problems).
The inetpub history folder saved my butt. I simply restored the two files in the root folder and wallah problem solved.
To install a backup of an older configuration, you can use the command:
c:\windows\system32\inetsrv\appcmd restore backup CFXHISTORY_xxxxxxxx
where CFXHISTORY_xxxxxxxx is a sub folder of C:\inetpub\history\.
Not sure what the command does besides copying files from that folder to the current configuration, but you should probably use it in case it does do something special.
Or you can just copy the file from the backup as explained in https://stackoverflow.com/a/14859645/2279059
I am aware of this tutorials
http://wix.tramontana.co.hu/tutorial/getting-started/putting-it-to-use
http://www.codeproject.com/KB/install/WixTutorial.aspx
... but I can't find a quick solution for installing web sites and configuring IIS.
Is it necessary to manually add each file of the site?
You don't need to add each file manually. Instead, you can use Paraffin to harvest the files needed from your web project.
I configured it so that it is automatically run during a build (local or on the server) by manually modifying the Wix project file to add a BeforeBuild action. Here is an example, you can use this as a starting point.
<Target Name="BeforeBuild">
<!-- Set the WebClient.wxs file as not read-only -->
<Exec Command="attrib -R "$(ProjectDir)WebClient.wxs"" />
<!-- Run paraffin to generate the wix component for the web client. This assumes that web project has already been packaged.
This is automatically done on the build server by setting the property 'DeployOnBuild' to true. -->
<Exec Command="paraffin -update WebClient.wxs -dir ..\RM.Web\obj\$(Platform)\$(Configuration)\Package\PackageTmp\" />
<!-- Set the WebClient.wxs file back as read-only -->
<Exec Command="attrib +R "$(ProjectDir)WebClient.wxs"" />
</Target>
I want to enable "Directory Browsing" for the for the following virtual web directory using WIX.
<iis:WebVirtualDir Id="LogsVirDir" Alias="Logs" Directory="ESGLOGFILES" />
How do I accomplish this using WIX?
Wouldn't a simpler solution be to use the web.config system.webserver property like :
<directoryBrowse enabled="true"/>
Based on my research Wix currently does not have any capability to enable Directory Browsing using the standard set of actions. The one way I have found to do this is using a combination of Wix Custom Actions and IIS's Appcmd.exe. Note this command will create a web.config file if one does not exist.
<CustomAction Id="EnableDirectoryBrowsing"
Execute="deferred"
ExeCommand='[WindowsFolder]system32\inetsrv\APPCMD.EXE set config "ESG Website/logs" /section:directoryBrowse /enabled:true'
Directory="TARGETDIR"
Return="check"
Impersonate="no"/>
<InstallExecuteSequence>
<Custom Action="EnableDirectoryBrowsing" Before="InstallFinalize">Not Installed</Custom>
</InstallExecuteSequence>
Im using wix v3.8
try adding ConfigurableDirectory in your Feature
ex: <Feature Id='TestName' Title='Test Web' ConfigurableDirectory='INSTALLDIR' Level='1'>
Use the following code
<Control Id="Browse" Type="PushButton" X="304" Y="210" Width="56" Height="17" Text="!(loc.CustomizeDlgBrowse)">
<Publish Event="SelectionBrowse" Value="BrowseDlg">1</Publish>
</Control>
Take the value of this in the variable you want and use it.
I have a TFS build set up to deploy an ASP.net project to a test server.
The build works great, and deploys to the test server fine, but instead of putting it into the \Website directory that my IIS webserver is configured for, it puts the build into \Website_20100511.6
Why is the date suffixed to the directory name? Is there a way to turn that off so I can publish directly to the \Website?
You don't want to have the build agent build to the actual location your site is running from. You need to add script to the end of the build process (tfsbuild.proj file) to take the code from the drop location and move it to the web server.
Something like this:
<Target Name="AfterDropBuild">
<Message Text="PortalFilesToPublish location is $(DropLocation)\$(BuildNumber)" Importance="Low" />
<CreateItem Include="$(DropLocation)\$(BuildNumber)\Default\_PublishedWebsites\MyWebPortal\**\*.*" Exclude="*.pdb" >
<Output ItemName="PortalFiles" TaskParameter="Include" />
</CreateItem>
<Copy
SourceFiles="#(PortalFiles)"
DestinationFiles="#(PortalFiles ->'\\testserver.test.lab\Test Lab\MyWebPortal\%(RecursiveDir)%(Filename)%(Extension)')"
ContinueOnError="true" />
</Target>