Publishing ASP.NET 3.5 Site Leaves Web.config Empty Due to providerOptions Element

橙三吉。 提交于 2019-12-29 09:37:52

问题


I am trying to publish a ASP.Net 3.5 site to an IIS 7.5 server using WebDAV and each time I do the config file winds up empty. The culprit is the providerOption elemet seen in the code below.

<system.codedom>
<compilers>
  <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="WarnAsError" value="false"/>
  </compiler>
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="OptionInfer" value="true"/>
    <providerOption name="WarnAsError" value="false"/>
  </compiler>
</compilers>

The FX_schema.xml file at C:\Windows\System32\inetsrv\config\schema is being used to validate the Web.config for the site and it doesn't contain providerOptions as part of the XML there. I could add something to allow for that modify the file to allow for it by adding something like this:

 <collection addElement = "providerOption">
  <attribute name = "name" required = "true" isUniqueKey = "true" type = "string" />
  <attribute name = "value" required = "true" type = "string" />
 </collection>

But I don't have any permissions to write to the schema file. This also looks like something others should be seeing and a quick search found some people are. The only option I have seen is "Just delete the codedom section" which means 3.5 things, like LINQ, will not work so that is a non-starter.

So how do I publish my Web Site to IIS 7.5 with the providerOption elements intact?


回答1:


Well, since I couldn't find anything specific I just went ahead and did what I thought might be the solution: I made my own file and placed it in with the schema files. I called it the inventive name ThreeFive.xml and placed it at C:\Windows\System32\inetsrv\config\schema. The entire contents of the file are as follows:

<configSchema>
    <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" />
                <attribute name="compilerOptions" type="string" />
                <collection addElement="providerOption">
                  <attribute name="name" required="true" isUniqueKey="true" type="string" />
                  <attribute name="value" required="true" type="string" />
                </collection>
            </collection>
        </element>
    </sectionSchema>
</configSchema>

I then published a 3.5 site that retrieved information from an appconfig setting and did some LINQ to make sure the config and the 3.5 were in effect. The config file was not blanked and the LINQ is working as expected so I am tempted to call this a solution.



来源:https://stackoverflow.com/questions/12680320/publishing-asp-net-3-5-site-leaves-web-config-empty-due-to-provideroptions-eleme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!