ASP.NET MVC - Problema NHaml sul file web.config
-
07-07-2019 - |
Domanda
Sto cercando di implementare le viste NHaml sulla mia applicazione e tutto funziona bene. Ma stranamente ricevo alcuni avvisi sui file web.config durante la pubblicazione dell'applicazione.
I miei parametri nhaml sono:
<configSections>
...
<section name="nhaml" type="NHaml.Configuration.NHamlConfigurationSection, NHaml"/>
</configSections>
<nhaml autoRecompile="true" templateCompiler="CSharp3" encodeHtml="false" useTabs="false" indentSize="2">
<assemblies>
<add assembly="MyApp"/>
</assemblies>
<namespaces>
<add namespace="MyApp" />
<add namespace="MyApp.Controllers" />
</namespaces>
</nhaml>
Quindi, è strano perché le viste haml vengono visualizzate senza problemi, ma ogni volta che apro il file web.config ricevo i seguenti avvisi:
Message 1 Could not find schema information for the element 'nhaml'. C:\inetpub\MyApp\Web.config 25 4 MyApp
Message 2 Could not find schema information for the attribute 'autoRecompile'. C:\inetpub\MyApp\Web.config 25 10 MyApp
Message 3 Could not find schema information for the attribute 'templateCompiler'. C:\inetpub\MyApp\Web.config 25 31 MyApp
Message 4 Could not find schema information for the attribute 'encodeHtml'. C:\inetpub\MyApp\Web.config 25 58 MyApp
Message 5 Could not find schema information for the attribute 'useTabs'. C:\inetpub\MyApp\Web.config 25 77 MyApp
Message 6 Could not find schema information for the attribute 'indentSize'. C:\inetpub\MyApp\Web.config 25 93 MyApp
Message 7 Could not find schema information for the element 'assemblies'. C:\inetpub\MyApp\Web.config 26 6 MyApp
Message 8 Could not find schema information for the element 'add'. C:\inetpub\MyApp\Web.config 27 8 MyApp
Message 9 Could not find schema information for the attribute 'assembly'. C:\inetpub\MyApp\Web.config 27 12 MyApp
Message 10 Could not find schema information for the element 'namespaces'. C:\inetpub\MyApp\Web.config 29 6 MyApp
Message 11 Could not find schema information for the element 'add'. C:\inetpub\MyApp\Web.config 30 8 MyApp
Message 12 Could not find schema information for the attribute 'namespace'. C:\inetpub\MyApp\Web.config 30 12 MyApp
Message 13 Could not find schema information for the element 'add'. C:\inetpub\MyApp\Web.config 31 8 MyApp
Message 14 Could not find schema information for the attribute 'namespace'. C:\inetpub\MyApp\Web.config 31 12 MyApp
Sto facendo qualcosa di sbagliato?
Grazie per l'attenzione. :)
Soluzione
Sembra che questi siano solo VS che ti dicono che gli elementi personalizzati non possono essere trovati all'interno dell'XSD per come dovrebbero apparire i file di configurazione. Lo stesso accade con Nhibernate.
Quindi non stai facendo nulla di male e puoi ignorare i messaggi. Sono solo informativi.
Basato su questo post del blog http://fgheysels.blogspot.com/ 2006/04 / net-20-potrebbe-non-trovare-schema.html
Potrei creare un XSD nhaml per la configurazione (allo stesso modo delle persone negligenti) ma non è in cima alla mia lista di priorità. Sentiti libero di provarci se i messaggi ti infastidiscono davvero.