ASP.Net 登录控制损坏

发布于 2024-07-26 00:19:08 字数 1198 浏览 3 评论 0原文

帮助! 我在登录页面上使用 ASP.Net 登录控件,但登录按钮似乎不再工作,并且验证事件未触发。 单击“登录”后,页面将返回到“登录”页面。

web.config 提取

<authorization>
 <deny users="?" />
  <allow users="*" />
</authorization>

<authentication mode="Forms">
  <forms loginUrl="Login.aspx" timeout="15" defaultUrl="Default.aspx" />
</authentication>

我还设置了 App_Themes 文件夹的路径,以便匿名用户可以访问,以便图像和样式表等显示正常。

登录控件本身的 DestinationUrl 属性设置为“Default.aspx”并且验证正在工作,就好像我省略了用户名或密码字段一样,页面上出现验证错误。

登录控制标记:

<asp:Login ID="Login1" runat="server" LoginButtonType="Image" 
  Width="557px" DestinationPageUrl="~/Default.aspx" 
  InstructionText="To login, please enter your username and password below."
  DisplayRememberMe="False" OnAuthenticate="Login1_Authenticate" LoginButtonImageUrl="~/App_Themes/RDCU/Images/submit.gif">
  <InstructionTextStyle Font-Names="Verdana" Font-Size="Small" ForeColor="#00A4E8" Height="40px" />
   <TitleTextStyle CssClass="header" HorizontalAlign="Left" />
   <TextBoxStyle Width="200px" />
   <LabelStyle Font-Bold="True" />
</asp:Login>

它以前曾有效,但我不认为我已更改任何内容以使其停止工作。

Help! I'm using the ASP.Net Login control on a Login page, but the Login button no longer appears to be working and the Authenticate event is not firing. On clicking Log In, the page just returns to the Login page.

web.config extract

<authorization>
 <deny users="?" />
  <allow users="*" />
</authorization>

<authentication mode="Forms">
  <forms loginUrl="Login.aspx" timeout="15" defaultUrl="Default.aspx" />
</authentication>

I have also set the path of my App_Themes folder to be accessible to anonymous users, so that images and stylesheets etc. appear OK.

The login control itself has its DestinationUrl property set to "Default.aspx" and validation is working, as if I omit either the Username or Password fields, I get validation errors appearing on the page.

Login control markup:

<asp:Login ID="Login1" runat="server" LoginButtonType="Image" 
  Width="557px" DestinationPageUrl="~/Default.aspx" 
  InstructionText="To login, please enter your username and password below."
  DisplayRememberMe="False" OnAuthenticate="Login1_Authenticate" LoginButtonImageUrl="~/App_Themes/RDCU/Images/submit.gif">
  <InstructionTextStyle Font-Names="Verdana" Font-Size="Small" ForeColor="#00A4E8" Height="40px" />
   <TitleTextStyle CssClass="header" HorizontalAlign="Left" />
   <TextBoxStyle Width="200px" />
   <LabelStyle Font-Bold="True" />
</asp:Login>

It has worked previously, but I don't believe I've changed anything to make it stop working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

软糯酥胸 2024-08-02 00:19:08

这可能是您的验证存在问题。

假设页面上有 ASP.Net 验证控件,它们可能会干扰登录控件已有的验证。 尝试将验证控件的 ValidationGroup 属性设置为登录控件的名称。 这会将它们放置在与登录控件相同的验证组中,从而保持验证的统一。

像这样的事情:

<asp:Login runat="server" ID="myLogin" DisplayRememberMe="false" 
     FailureText="Invalid user name or password" 
     UserNameLabelText="User Name:" TitleText=""
     LoginButtonText="Submit" TextBoxStyle-Width="175px">
</asp:Login>
<asp:CustomValidator runat="server" ID="cvTandC"
     ClientValidationFunction="validateTandC" Display="Dynamic"
     EnableClientScript="true" ErrorMessage="Please check to continue." 
     ForeColor="Red" ValidateEmptyText="true" 
     ValidationGroup="myLogin"></asp:CustomValidator>

注意最后一行的验证组。

This may be a problem with your validation.

Assuming you have ASP.Net validation controls on the page, they can interfere with the validation that already exists for the login control. Try setting the ValidationGroup property of your validation controls to be the name of the Login control. This will place them in the same validation group as the login control, thus keeping the validation unified.

Something like this:

<asp:Login runat="server" ID="myLogin" DisplayRememberMe="false" 
     FailureText="Invalid user name or password" 
     UserNameLabelText="User Name:" TitleText=""
     LoginButtonText="Submit" TextBoxStyle-Width="175px">
</asp:Login>
<asp:CustomValidator runat="server" ID="cvTandC"
     ClientValidationFunction="validateTandC" Display="Dynamic"
     EnableClientScript="true" ErrorMessage="Please check to continue." 
     ForeColor="Red" ValidateEmptyText="true" 
     ValidationGroup="myLogin"></asp:CustomValidator>

Note the validation group on the last line.

蓬勃野心 2024-08-02 00:19:08

我设法自己修复了这个问题,方法是将登录控件转换为模板,更改一些属性,然后将其重置为原始布局。

我不确定为什么这会产生影响(也许它强制重新编译或其他什么),但它现在正在工作。

感谢那些试图提供帮助的人。

I managed to fix it myself by converting the Login control to a template, changing some properties, then resetting it to its original layout.

I'm not sure why this would make a difference (perhaps it forced a re-compile or something) but it's working now.

Thanks to those who tried to help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文