代码之家  ›  专栏  ›  技术社区  ›  Brian

如何将Microsoft Identity设置为符合默认文件名[重复]

  •  0
  • Brian  · 技术社区  · 7 年前

    我遇到的一个问题是:如果我将LoginPath设置为“/account/”,那么注销的用户最终会出现无限重定向循环(不是真的;它会一直扩展returnURL,直到服务器因查询字符串过长而阻止请求为止。这发生在 /account/ 但是 /account/default.aspx

    我试着使用 UseFileServer 设置 DefaultFileNames path="." inheritInChildApplications=false" 而不是 path="default.aspx" ,但这会导致“Config section'system.web/authorization'ready defined”异常,可能是因为它与前面的system.web声明重叠。

    我意识到有几种可能的解决办法:

    • 容忍 default.aspx 在路径中:
    • 使用 MapPageRoutes
    • 将web.config设置为allow/account,然后使用位置路径手动禁用每个子目录

    有没有办法让Microsoft Identity相信 /帐目/ 在不使用上述要点中的解决方法的情况下不需要身份验证?

    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>
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Brian    7 年前

    投票结束我自己的问题作为重复。作为参考,可以通过修改根web.config来解决此问题,如下所示:

    <urlMappings>
      <add url="~/account/" mappedUrl="~/account/default.aspx"/>
    </urlMappings>
    

    不知怎的,我完全找不到 https://stackoverflow.com/a/19154854/18192 在调查这个问题的时候。