1

我正在尝试将自定义表单身份验证应用于我已经应用 URL 重写的网站。Application_Startglobal.asax文件中使用此代码。

routes.MapPageRoute("bill-details",                 //Route Name
                    "{billno}",                     //URL with Parameters
                    "~/CallCenter/BillDetails.aspx" //Webforms page to Handle it.
                    );

但是当我尝试重写 Loginpage Url 时,我无法重写它。

<forms loginUrl="/Login.aspx" name="MyCustomAuthentication" timeout="30"/>

实际问题是,当我打开一个页面时,它会检查身份验证,如果它没有经过身份验证,那么它会重定向到 Login.aspx 页面。

它表明mywebsite.com/Login.aspx?ReturnUrl="..." 我无法重写它。如果我不能删除返回 URL,那么我可以放置Login而不是Login.aspx??

如果我在这篇文章中使用此代码->如何从 url 中删除 returnurl?

如果我使用它,那么控制会一遍又一遍地循环并显示 - 重定向太多。我认为问题是,当控件像 一样进入Login页面时mywebsite.com/Login,它会检查身份验证并重定向到Login.aspx页面。并且您的代码再次重定向到登录页面。这个循环继续。

我也不需要返回 URL,因为我的用户必须先登录才能访问我的网站。

那么你能帮我删除返回网址吗?还有在 URL 重写 ??

这个我解决不了!!

检查我的网站。-> http://orders.maabookings.com UserId - temp Password - temp

在这个登录页面中,它显示为 http://orders.maabookings.com/Login.aspx?ReturnUrl=%2f 我需要这个我该http://orders.maabookings.com/Login 怎么做?

4

1 回答 1

1

将 web.config 添加到您的 Login.aspx 放置的文件夹中

<?xml version="1.0"?>
<configuration>
  <system.web>
    <authorization>
      <deny users="?"/>
    </authorization>
  </system.web>
  <location path="Login.aspx">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
</configuration>

在 Global.asax 中

Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
    ' Fires upon attempting to authenticate the use

    Dim _URL As String = Request.Url.ToString

    If _URL.Contains("ReturnUrl") Then
        Response.Redirect("/Login")
    End If
End Sub

我认为这对你有帮助。

于 2014-10-30T11:15:43.690 回答