2015-05-13 4 views
0

Я пытаюсь разработать приложение, которое использует пакет SAML2.dll (который я загрузил с помощью NuGet). Чтобы правильно настроить мое приложение, мы должны добавить несколько разделов в файле Web.config:Пользовательский раздел Web.config не распознается

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    **<section name="saml2" type="SAML2.Config.Saml2Section, SAML2" />** 
    </configSections> 
    <connectionStrings>...</connectionStrings> 
    <appSettings>...</appSettings> 
    <system.web>...</system.web> 
    <system.webServer> 
    <modules> 
     <remove name="FormsAuthentication" /> 
    </modules> 
    **<handlers> 
     <remove name="SAML2.Protocol.Saml20SignonHandler" /> 
     <remove name="SAML2.Protocol.Saml20LogoutHandler" /> 
     <remove name="SAML2.Protocol.Saml20MetadataHandler" /> 
     <add name="SAML2.Protocol.Saml20SignonHandler" verb="*" path="Login.ashx" type="SAML2.Protocol.Saml20SignonHandler, SAML2" /> 
     <add name="SAML2.Protocol.Saml20LogoutHandler" verb="*" path="Logout.ashx" type="SAML2.Protocol.Saml20LogoutHandler, SAML2" /> 
     <add name="SAML2.Protocol.Saml20MetadataHandler" verb="*" path="Metadata.ashx" type="SAML2.Protocol.Saml20MetadataHandler, SAML2" /> 
    </handlers>** 
    </system.webServer> 
    <runtime>...</runtime> 
    <entityFramework>...</entityFramework> 

    **<saml2> 
    <serviceProvider id="urn:issuer" server="http://localhost:3301/"> 
     <endpoints> 
     <endpoint localpath="Login.ashx" type="signon" redirectUrl="~/AuthenticatedHomePage" /> 
     <endpoint localpath="Logout.ashx" type="logout" redirectUrl="~/HomePage" /> 
     <endpoint localpath="Metadata.ashx" type="metadata" /> 
     </endpoints> 
     <nameIdFormats allowCreate="true"> 
     <add format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient" /> 
     </nameIdFormats> 
     <authenticationContexts comparison="Exact"> 
     <add context="urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport" referenceType="AuthnContextClassRef" /> 
     </authenticationContexts> 
    </serviceProvider> 
    <identityProviders metadata="C:\Users\myUser\Desktop\testMetadata\metadata_Kit_net.xml" /> 
    <metadata> 
     <contacts> 
     <contact type="Administrative" company="" givenName="" surName="" email="" phone="" /> 
     </contacts> 
     <requestedAttributes> 
     <add name="urn:cn" /> 
     </requestedAttributes> 
    </metadata> 
    </saml2>** 
</configuration> 

Вопрос заключается в том, что сессия тег не имеет признанных тегов, у меня 39 сообщений типа (один для каждого элемента внутри тега):

impossible to find schema information for the element 'saml2'. impossible to find schema information for the element 'serviceProvider'. impossible to find schema information for the element 'id'. ...

Я посмотрел в исходный код моей DLL (SAML2.dll) и швы имеют все определения тегов (как написано в первой части Web.config: ):

using System.Configuration; 

namespace SAML2.Config 
{ 
    /// <summary> 
    /// SAML2 Configuration Section. 
    /// </summary> 
    public class Saml2Section : ConfigurationSection 
    { 
     /// <summary> 
     /// Gets the section name. 
     /// </summary> 
     public static string Name { get { return "saml2"; } } 

     #region Elements 

     /// <summary> 
     /// Gets or sets the actions to perform on successful processing. 
     /// </summary> 
     /// <value>The actions.</value> 
     [ConfigurationProperty("actions")] 
     public ActionCollection Actions 
     { 
      get { return (ActionCollection)base["actions"]; } 
      set { base["actions"] = value; } 
     } 

     /// <summary> 
     /// Gets or sets the identity providers. 
     /// </summary> 
     /// <value>The identity providers.</value> 
     [ConfigurationProperty("identityProviders")] 
     public IdentityProviderCollection IdentityProviders 
     { 
      get { return (IdentityProviderCollection)base["identityProviders"]; } 
      set { base["identityProviders"] = value; } 
     } 

     /// <summary> 
     /// Gets or sets the metadata. 
     /// </summary> 
     /// <value>The metadata.</value> 
     [ConfigurationProperty("metadata")] 
     public MetadataElement Metadata 
     { 
      get { return (MetadataElement)base["metadata"]; } 
      set { base["metadata"] = value; } 
     } 

     /// <summary> 
     /// Gets or sets the service provider. 
     /// </summary> 
     /// <value>The service provider.</value> 
     [ConfigurationProperty("serviceProvider")] 
     public ServiceProviderElement ServiceProvider 
     { 
      get { return (ServiceProviderElement)base["serviceProvider"]; } 
      set { base["serviceProvider"] = value; } 
     } 

     ... 

Когда я вызываю URL-адрес http://localhost:3301/Login.ashx, у меня есть ошибка: {"Атрибут 'localpath' не распознан. (C: \ Users \ MyUser \ документы \ визуально студии 2013 \ Projects \ saml20app \ saml20app \ web.config строки 98) "}, и он указывает точно на линии

<endpoint localpath="Login.ashx" type="signon" redirectUrl="~/AuthenticatedHomePage" /> 

Может кто-то пожалуйста, помогите мне ? эта ошибка

заранее спасибо за вашу помощь, MARC

ответ

1

Got пытался пытаться получить эту работу, так что я открыл собрание с ILSpy, чтобы посмотреть, что он хотел:

<endpoint localPath="Login.ashx" type="SignOn" redirectUrl="~/AuthenticatedHomePage" /> 
<endpoint localPath="Logout.ashx" type="Logout" redirectUrl="~/HomePage" /> 
<endpoint localPath="Metadata.ashx" type="Metadata" /> 

Атрибут type в примере web.config также делает его недовольным. К счастью, он позволяет вам узнать перечисленные значения, которые он ожидает.

Надеюсь, что эта помощь.

Смежные вопросы