如何设置 Microsoft Identity 以遵循默认文件名
How can I set Microsoft Identity to respect default file names
我正在尝试从表单身份验证/成员身份迁移到 asp.net 身份。
我遇到的一个问题:如果我将 LoginPath 设置为“/account/”,注销的用户最终会出现无限重定向循环(不是真的;它会不断扩展 returnURL,直到服务器阻止对 having 的请求过长的查询字符串)。这发生在 /account/
,但注销用户可以访问 /account/default.aspx
。我认为问题在于 OWIN 中间件以某种方式对默认文档的处理方式不同于表单 authentication/IIS。当前,"default.aspx" 配置为默认文档。
我尝试使用 UseFileServer
设置 DefaultFileNames
以包含 "default.aspx",但这似乎没有帮助。我也尝试使用 path="." inheritInChildApplications=false"
而不是 path="default.aspx"
,但这导致了 "Config section 'system.web/authorization' already defined" 异常,大概是因为它与之前的 system.web 声明重叠。
我知道有几种可能的解决方法:
- 在路径中容忍
default.aspx
:
- 使用
MapPageRoutes
而不是依赖默认页面
- 设置 web.config 允许 /account 然后使用位置路径手动禁用每个子目录
有没有办法在不使用上述要点中的解决方法的情况下说服 Microsoft Identity 加载 /account/
不需要身份验证?
public void Configuration(IAppBuilder app)
{
app.UseFileServer(new FileServerOptions() {
DefaultFilesOptions = {DefaultFileNames = {"default.aspx"}}});
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/account/")
});
}
<!--/account/web.config-->
<configuration>
<system.web>
<authorization>
<allow roles="activeuser" />
<deny users="*" />
</authorization>
</system.web>
<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
</configuration>
投票结束我自己的重复问题。作为参考,可以通过如下修改根web.config来解决:
<urlMappings>
<add url="~/account/" mappedUrl="~/account/default.aspx"/>
</urlMappings>
不知怎么的,我在调查这个问题时完全找不到。
我正在尝试从表单身份验证/成员身份迁移到 asp.net 身份。
我遇到的一个问题:如果我将 LoginPath 设置为“/account/”,注销的用户最终会出现无限重定向循环(不是真的;它会不断扩展 returnURL,直到服务器阻止对 having 的请求过长的查询字符串)。这发生在 /account/
,但注销用户可以访问 /account/default.aspx
。我认为问题在于 OWIN 中间件以某种方式对默认文档的处理方式不同于表单 authentication/IIS。当前,"default.aspx" 配置为默认文档。
我尝试使用 UseFileServer
设置 DefaultFileNames
以包含 "default.aspx",但这似乎没有帮助。我也尝试使用 path="." inheritInChildApplications=false"
而不是 path="default.aspx"
,但这导致了 "Config section 'system.web/authorization' already defined" 异常,大概是因为它与之前的 system.web 声明重叠。
我知道有几种可能的解决方法:
- 在路径中容忍
default.aspx
: - 使用
MapPageRoutes
而不是依赖默认页面 - 设置 web.config 允许 /account 然后使用位置路径手动禁用每个子目录
有没有办法在不使用上述要点中的解决方法的情况下说服 Microsoft Identity 加载 /account/
不需要身份验证?
public void Configuration(IAppBuilder app)
{
app.UseFileServer(new FileServerOptions() {
DefaultFilesOptions = {DefaultFileNames = {"default.aspx"}}});
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/account/")
});
}
<!--/account/web.config-->
<configuration>
<system.web>
<authorization>
<allow roles="activeuser" />
<deny users="*" />
</authorization>
</system.web>
<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
</configuration>
投票结束我自己的重复问题。作为参考,可以通过如下修改根web.config来解决:
<urlMappings>
<add url="~/account/" mappedUrl="~/account/default.aspx"/>
</urlMappings>
不知怎么的,我在调查这个问题时完全找不到。