我需要添加对传递到我的adfs登录页面的表单变量的检查,但是当我向内置的Page_Load函数添加任何内容时,它会中断。
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"%>
<%@ 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 );
}
}
}
答案 0 :(得分:0)
你没有提到你是如何添加代码或它是如何中断的,但总的来说,当我直接修改文件时,我发现了问题。
鉴于ADFS只是另一个IIS应用程序,我对此方法感到非常高兴: