I need to add a check for form variables that are passed to my adfs login page but when I add anything to the built-in Page_Load function it breaks.
FormsSignIn.aspx
<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true" ValidateRequest="false"
CodeFile="FormsSignIn.aspx.cs" Inherits="FormsSignIn" Title="<%$ Resources:CommonResources, FormsSignInPageTitle%>"
EnableViewState="false" runat="server"%>
<%@开发者_如何学Python OutputCache Location="None" %>
<asp:Content ID="FormsSignInContent" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="GroupXLargeMargin"><asp:Label Text="<%$ Resources:CommonResources, FormsSignInHeader%>" runat="server" /></div>
<h3>*******I Want lbl1.Text to output here from the codefile.</h3>
<table class="UsernamePasswordTable">
<tr>
<td>
<span class="Label"><asp:Label Text="<%$ Resources:CommonResources, UsernameLabel%>" runat="server" /></span>
</td>
<td>
<asp:TextBox runat="server" ID="UsernameTextBox" ></asp:TextBox>
</td>
<td class="TextColorSecondary TextSizeSmall">
<asp:Label Text="<%$ Resources:CommonResources, UsernameExample%>" runat="server" />
</td>
</tr>
<tr>
<td>
<span class="Label"><asp:Label Text="<%$ Resources:CommonResources, PasswordLabel%>" runat="server" /></span>
</td>
<td>
<asp:TextBox runat="server" ID="PasswordTextBox" TextMode="Password" ></asp:TextBox>
</td>
<td> </td>
</tr>
<tr>
<td></td>
<td colspan="2" class="TextSizeSmall TextColorError">
<asp:Label ID="ErrorTextLabel" runat="server" Text="" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<div class="RightAlign GroupXLargeMargin">
<asp:Button ID="SubmitButton" runat="server" Text="<%$ Resources:CommonResources, FormsSignInButtonText%>" OnClick="SubmitButton_Click" CssClass="Resizable"/>
</div>
</td>
<td> </td>
</tr>
</table>
</asp:Content>
FormsSignIn.Aspx.cs
using System;
using Microsoft.IdentityServer.Web;
using Microsoft.IdentityServer.Web.UI;
public partial class FormsSignIn : FormsLoginPage
{
protected void Page_Load( object sender, EventArgs e )
{
//Uncommented, this breaks!!!!!!!!!!!!!!
/* if ( !string.IsNullOrEmpty(Page.Request.Form["foo"]) ) {
lbl1.Text = Page.Request.Form["foo"].Trim();
} else {
lbl1.Text = "not found";
} */
}
protected void HandleError( string message )
{
ErrorTextLabel.Visible = true;
ErrorTextLabel.Text = Resources.CommonResources.IncorrectUsernameText;
}
protected void SubmitButton_Click( object sender, EventArgs e )
{
try
{
SignIn( UsernameTextBox.Text, PasswordTextBox.Text );
}
catch ( AuthenticationFailedException ex )
{
HandleError( ex.Message );
}
}
}
You haven't mentioned how you added the code or how it breaks but, in general, I have found problems when I modify the files directly.
Given that ADFS is just another IIS application, I have more joy following this approach:
Modifying and Securing the ADFS 2 Web Application
精彩评论