How to upload web.config file using WebDAV on IIS7? - asp.net-mvc

I want to copy an ASP.NET MVC website to a remote IIS 7 server using WebDAV. I have created a site in IIS, enabled WebDAV and assigned a special application pool I have named "WebDAV Application Pool". Using a Windows 7 or Vista client I'm able to mount the remote site as a network drive. So far, so good.
However, I have problems uploading web.config files to the remote site. One problem is that as soon as a web.config has been uploaded it is used to configure the WebDAV site. The web.config file in a Views folder of a MVC project effectively blocks access to that folder.
To work around this problem I have configured the application pool in the applicationHost.config file:
<configuration>
<applicationPools>
<add name="WebDAV Application Pool"
autoStart="true"
enableConfigurationOverride="false" />
</applicationPools>
</configuration>
The interesting part is the 'enableConfigurationOverride` attribute:
When true, indicates that delegated settings in Web.config files will processed for applications within this application pool. When false, all settings in Web.config files will be ignored for this application pool.
Doing this makes it possible to upload a web.config file to the Views folder without breaking access to the folder.
However, I'm still unable to upload a web.config file to the root folder. I have the following settings in the applicationHost.config file to ensure that request filtering doesn't interfere with WebDAV:
<configuration>
<location path="webdav.mysite.tld">
<system.webServer>
<security>
<requestFiltering>
<fileExtensions applyToWebDAV="false" />
<verbs applyToWebDAV="false" />
<hiddenSegments applyToWebDAV="false" />
</requestFiltering>
</security>
</system.webServer>
</location>
</configuration>
In particular hiddenSegments will normally block access to web.config but setting the applyToWebDAV attribute to false should ensure that this file isn't blocked when using WebDAV.
Unfortunately, I'm still unable to copy my web.config file to the root folder of the site. Doing drag and drop in Windows Explorer to the mapped WebDAV network drive will result in the following error message:
Error 0x80070057: The parameter is incorrect.
On the wire it seems that the HTTP status 400 Bad Request is returned.
Is there anything I can do to configure WebDAV on IIS 7 to avoid this problem?
Followup
Currently I'm unable to reproduce the problem I described above. Perhaps I had to restart something or some other unknown factor fixed my problem. The bottom line is that I now can publish a web site using WebDAV.

1) Open up %windir%\system32\inetsrv\config\schema\WEBDAV_schema
2) Add the following inside of the configSchema section
<sectionSchema name="system.codedom">
<element name="compilers">
<collection addElement="compiler" removeElement="remove" clearElement"clear">
<attribute name="language" type="string" isCombinedKey="true"/>
<attribute name="extension" type="string" isCombinedKey="true"/>
<attribute name="type" type="string"/>
<attribute name="warningLevel" type="int"/>
<collection addElement="providerOption">
<attribute name="name" type="string" isUniqueKey="true"/>
<attribute name="value" type="string"/>
</collection>
</collection>
</element>
</sectionSchema>

Related

IIS Application The requested page cannot be accessed because the related configuration data for the page is invalid

I am running a .Net 6.0 Web API application that works fine on my dev machine. I am trying to deploy to IIS running on a windows Server
the web.config is
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Zimpla.WebApi.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 0214ca6f-0fd4-4643-92b7-4202aaa1024a-->
It has a separate application for the directory and I get the following error
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Every single page I go to in IIS Manager says "there was an error performing this operation" - filename c:\inetpub\wwwroot\logistics\web.config Error:
IIS and users have read and execute access to the whole directory. What am I missing?
Have you installed the .NetCore Runtime before hosting your .Net 6.0 Web application? If not, please install it. Restart your site and again try to check for the issue.
This problem occurs because the ApplicationHost.config or Web.config file contains a malformed or unidentified XML element. IIS can't identify the XML elements of the modules that are not installed. For example, IIS URL Rewrite module.
You could fix the error with the steps below.
Delete the malformed XML element from the ApplicationHost.config or Web.config file.
Check the unidentified XML elements, and then install the relevant IIS modules.
If you have the HRESULT code(something like 0x8007000d) then you could refer to the document below to check the error cause/ solution for that specific HRESULT code.
Ref: HTTP Error 500.19 - internal server error when you open an IIS Webpage

How to deploy Dart server to IIS

I want to deploy a basic dart server that uses shelf to an IIS server.
I ran the command dart compile exe and tried to place the executable along with the web.config file in a file system. I set up the workpool with the settings I need. I have a DNS ready which is mywebsite.reu.po and set up the proper bindings for it. It gives me a 503 error something about handlers. The server host name is localhost and the port is whatever APSNET_PORT is. If nothing is found in that port, then it grabs port 4000.
Here is what I have in my web.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\server.exe" />
</system.webServer>
</configuration>
So I figured out the solution for this. I had to change the identifier for the pool since there are multiple admin accounts for the IIS. However, only one account has the ability to do hosting. Go to the pool, advance settings, and change the identifier with the right admin credentials.

IIS Application Pool Identity permissions reset on every Visual Studio app Publish

Following the instructions in this questions I can successfully change the permissions for the application pool identity
However, after I publish the web app...
The application pool identity's has been reset to just Read
How can I give the application pool identity full permissions even after I re-publish the web app? The same behavior also occurs if I give IUSR full permissions.
As far as I know, if you use Web Deploy from Visual Studio, the publish will overwrite the ACLs on the server by clearing them to the inherited defaults of the parent.
To avoid update ACL each time when you publish your web application.
You could try to add below command in your PublishProfiles's pubxml.
<IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>
Details publish profile as below:
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>http://localhost:9825/</MSDeployServiceURL>
<DeployIisAppPath>WebFormApplication</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>InProc</MSDeployPublishMethod>
<EnableMSDeployBackup>False</EnableMSDeployBackup>
<UserName />
<_SavePWD>False</_SavePWD>
<IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="DefaultConnection" Order="1" Enabled="False">
<Destination Path="" />
<Object Type="DbCodeFirst">
<Source Path="DBContext" DbContext="WebFromIdentityTest.Models.ApplicationDbContext, WebFromIdentityTest" Origin="Configuration" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String" />
</ItemGroup>
</Project>
Then you will find the permission will not be changed after you publish the application.

How do you set the root page in an AppHarbor ASP.NET MVC website?

I'm publishing an ASP.NET Web Application (this is the default application with VS2013) and it publishes just fine. However when I visit my application
http://someapp.apphb.com
I get the "Welcome to nginx" page. However http://someapp.apphb.com/Home works.
Is there a setting on AppHarbor that I need to change, or do I need to make a change to my WebApp?
You can set default document in Web config file
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.html" />
</files>
</defaultDocument>
</system.webServer>
</configuration>

Log4Net works on Dev machine, fails when deployed to shared host (using same db/connstring)

I have log4net configured and working fine on my local machine, however when I deploy to my host (godaddy) it fails silently. I am using the same database/config file on my dev machine, and on the host. My log4net reference is set to copy local, and the log4net.dll, .pdb, and .xml exist in the bin on the host. This is an asp.net mvc app.
Edit: No exceptions are thrown, and the application runs as expected (minus the logging)
This is running on SQL Server 2005
The webhost is IIS 7
salient details of my config are:
<root>
<level value="DEBUG" />
<appender-ref ref="AdoNetAppender" />
</root>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Anybody have any ideas on things to check?
In my experience, log4net usually swallows any internal errors, simply resulting in log statements that do not produce any results.
What you may want to try is enable log4net's internal logging. You can do this by adding the following to your appSettings section:
<add key="log4net.Internal.Debug" value="true" />
This sets the property LogLog.InternalDebugging to true. log4net will now log to the standard output and error streams and to configured trace listeners.
You can use the following configuration to capture any messages logged to tracing:
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="myListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="c:\TextWriterOutput.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
All messages logged by log4net internally will appear in TextWriterOutput.log. If you get a SecurityException when you add the trace listener to your configuration, then very probably the apppool identity does not have sufficient rights to create a file at the specified location (in the example: c:\). Try another location or give the apppool identity sufficient rights.
I've just been able to resolve this problem by downloading and using the latest build of log4net (revision 1072765) from SVN repository http://svn.apache.org/viewvc/logging/log4net/trunk/
Apparently this problem has been fixed long time ago but who knows when log4net 1.2.11 is going to be released.

Resources