1

我如何配置 StarterSTS 附带的动态联合元数据生成器 http 处理程序以与 ASP.NET MVC 4 一起工作,现在我在 IIS 7 上的 web.config 中得到了这个配置,但浏览器返回 404 not found

<!-- handler to dynamically generate WS-Federation metadata -->
<location path="FederationMetadata/2007-06">
    <system.webServer>
        <handlers>
            <add name="MetadataGenerator" path="FederationMetadata.xml" verb="GET" type="Thinktecture.IdentityServer.WSFedMetadataGenerator,Thinktecture" />
        </handlers>
    </system.webServer>
    <system.web>
        <httpHandlers>
            <add path="FederationMetadata.xml" verb="GET" type="Thinktecture.IdentityServer.WSFedMetadataGenerator,Thinktecture" />
        </httpHandlers>
    </system.web>
</location>

404 未找到

https://localhost/website/FederationMetadata/2007-06/

4

1 回答 1

0

好的,这是它不起作用的事实。所以这就是我所做的,

  • 创建了一个名为它的新 asp.net mvc 控制器FederationMetadata

  • 复制代码以在 Index 操作方法中生成联邦元数据

  • 始终指向https://<pc:name>/stsvirtualdirectoryname/FederationMetadata/获取联邦元数据 xml 文档

代码

        if (STS.Configuration.Endpoints.WSFedMex)
        {
            EnsureInitialized();
            var serializer = new MetadataSerializer();
            var sb = new StringBuilder(512);
            serializer.WriteMetadata(XmlWriter.Create(new StringWriter(sb),new XmlWriterSettings { OmitXmlDeclaration = true }), _entity);
            return new ContentResult(){Content = sb.ToString(),ContentEncoding = Encoding.UTF8,ContentType = "text/xml"};
        }
        else
        {
            throw new HttpException(404, "Not found");
        }
于 2013-01-17T17:00:23.333 回答