更新时间:2023-02-25 16:58:52
发布你的页面linked实际上了解MVC确实工作。周围的授权控制踢MVC框架有一个机会来处理请求之前:
The location tag solution posted on the page you linked to actually does work for MVC. The authorization controls around that kick in before the MVC framework has a chance to handle the request:
<configuration>
<location path="~/MyAnonymousController">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
</configuration>
另外请注意,你可以把子目录的Web.config文件在您的应用程序。因此,例如,你可以把你的匿名访问控制器在它自己的子目录,并与一个位置标记,目录添加一个web.config,允许在该目录中的一切匿名访问:Web.config:在位置和授权通配符