混合的ASP.NET站点表单身份验证重定向到错误的位置

时间:2012-10-23 22:45:09

标签: asp.net asp-classic forms-authentication

在我的网络配置

<authorization>
    <deny users="?" />
    <allow roles="Employee" />
</authorization>
<authentication mode="Forms">
  <forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>

然后当我进入页面

    HTTP/1.1 302 Found
    Cache-Control: private
    Content-Type: text/html; charset=utf-8
    Location: /Account/Login?ReturnUrl=%2f
    Server: Microsoft-IIS/7.5
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    Date: Tue, 23 Oct 2012 22:34:55 GMT
    Content-Length: 145

    <html><head><title>Object moved</title></head><body>
    <h2>Object moved to <a href="/Account/Login?ReturnUrl=%2f">here</a>.</h2>
    </body></html>

为什么LogOn不给我这个而是登录?

IIS 7.5

网站

  • Classic Asp
  • ASP.Net

使用来自

的表单auth“hack”

http://weblogs.asp.net/scottgu/archive/2007/03/04/tip-trick-integrating-asp-net-security-with-classic-asp-and-non-asp-net-urls.aspx

1 个答案:

答案 0 :(得分:1)

将此密钥添加到您的web.config:

<appSettings>
  <add key="loginUrl" value="~/Account/LogOn" />
</appSettings> 

显然,DLL内部可能会有一些重定向到另一个“loginUrl”,特别是如果WebMatrix dll在路径中。