0
我的ASP.NET web應用程序使用Windows Authentication
,我只想啓用anonymous
用戶能夠輸入一個文件夾(我們稱之爲"XYZ"
)。 所以在XYZ
我必須在IIS中創建一個web配置:IIS 10.0 - 一個應用程序文件夾的AllowAnonymous(控制器不起作用)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</configuration>
裏面的XYZ
我有一個HTML頁面,並輸入網址,如:
www.site.com/XYZ/htmlPage.html
它打開沒有詢問權限和一切都很好。 但是,當我對我的控制器操作(控制器在內部的XYZ
內)做同樣的處理時,我得到401
錯誤代碼。
控制器:
[AllowAnonymous]
public class TestController : Controller
{
[AllowAnonymous]
public ActionResult Index()
{
return Content("Test content");
}
}
路由:
routes.MapRoute(
name: "XYZRoute",
url: "XYZ/{controller}/{action}/{id}",
defaults: new { controller = "Test", action = "Index", id = UrlParameter.Optional });
不知道在哪裏,我犯了一個錯誤