我有一个基本的网络API应用程序,试图支持IntegratedWindowsAuthentication&匿名。示例代码如下,
using (WebApp.Start("http://localhost:8080/", (app) =>
{
HttpConfiguration config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
config.EnsureInitialized();
HttpListener listener = (HttpListener)app.Properties["System.Net.HttpListener"];
listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication | AuthenticationSchemes.Anonymous;
app.UseWebApi(config);
}))
public class TestController : ApiController
{
[Authorize]
[Route("Secret")]
public int Get()
{
return 42;
}
[Route("Public")]
public int GetNoSecurity()
{
return 42;
}
}
期望是〜/ Secret需要凭据而〜/ Public不需要凭据。
与Fiddler的关系不错,但浏览器却没有。从chrome / IE点击〜/ Secret不会弹出凭证消息框。