如何配置StarterSTS附带的动态联合元数据生成器http处理程序与ASP.NET MVC 4一起使用,现在我在IIS 7上的web.config中获得了此配置,但浏览器返回404未找到
<!-- 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/
答案 0 :(得分:0)
好的,这是事实,它不起作用。所以这就是我所做的,
创建了一个名为FederationMetadata
的新asp.net mvc控制器
复制代码以在“索引”操作方法
始终指向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");
}