Hi
When I submit Login button without any FBA user details I am getting the below screen and also when entered incorrect user details I am not getting any error message.
Server Error in '/' Application.
Value cannot be null.
Parameter name: password
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: password
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
|
below is my code for login.aspx
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="GG.Login.Custom.Layouts.GG.Login.Custom.Login" MasterPageFile="~/_layouts/15/errorv15.master" %>
<asp:Content ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
<SharePoint:EncodedLiteral runat="server" EncodeMethod="HtmlEncode" Id="ClaimsFormsPageTitle" />
</asp:Content>
<asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
<div id="SslWarning" style="color: red; display: none">
<SharePoint:EncodedLiteral runat="server"
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="GG.Login.Custom.Layouts.GG.Login.Custom.Login" MasterPageFile="~/_layouts/15/errorv15.master" %>
<asp:Content ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
<SharePoint:EncodedLiteral runat="server" EncodeMethod="HtmlEncode" Id="ClaimsFormsPageTitle" />
</asp:Content>
<asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
<div id="SslWarning" style="color: red; display: none">
<SharePoint:EncodedLiteral runat="server"
EncodeMethod="HtmlEncode" Id="ClaimsFormsPageMessage" />
</div>
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
<div id="Banner">
<img src="DesignFiles/Images/Banner.png" /> </div>
<table>
<td>
<h1><b>Introduction</b></h1>
</table>
</html>
<link href="/_layouts/15/GG.Login.Custom/DesignFiles/Css/customLogin.css" rel="stylesheet" />
<asp:Login ID="signInControl" onLoggingin="OnLoggingIn" FailureText="<%$Resources:wss, login_pageFailureText%>" runat="server" Width="100%">
<LayoutTemplate>
<asp:Label ID="lblError" runat="server" Width="94%"></asp:Label>
<div id="customLoginMain">
<table>
<tr id="customLoginHeader">
<td colspan="2" align="center"><b>Grampian Guidance Login</b></td>
</tr>
<tr>
<td nowrap="nowrap">
<SharePoint:EncodedLiteral runat="server" text="User Name" EncodeMethod='HtmlEncode' />
</td>
<td width="100%">
<asp:TextBox ID="UserName" autocomplete="off" runat="server" class="ms-inputuserfield userNameIcom" Width="94%" />
</td>
</tr>
<tr>
<td nowrap="nowrap">
<SharePoint:EncodedLiteral runat="server" text="Password" EncodeMethod='HtmlEncode' />
</td>
<td width="100%">
<asp:TextBox ID="Password" TextMode="Password" autocomplete="off" runat="server" class="ms-inputuserfield passwordIcom" Width="94%" /></td>
</tr>
<div class="ForgotPassword"><asp:HyperLink ID="hypforget" Text="Forgot Your Password?" Visible="false" runat="server" /></div>
<div class="ErrorMessage"><asp:Label ID="Label1" runat="server" Text="Label" Visible="false"></asp:Label></div>
<tr>
<td colspan="2" align="center">
<asp:checkbox id="rememberme" text="Remember Me" runat="server" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
</div>
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
<div id="Banner">
<img src="DesignFiles/Images/Banner.png" /> </div>
<table>
<td>
<h1><b>Introduction</b></h1>
</table>
</html>
<link href="/_layouts/15/GG.Login.Custom/DesignFiles/Css/customLogin.css" rel="stylesheet" />
<asp:Login ID="signInControl" onLoggingin="OnLoggingIn" FailureText="<%$Resources:wss, login_pageFailureText%>" runat="server" Width="100%">
<LayoutTemplate>
<asp:Label ID="lblError" runat="server" Width="94%"></asp:Label>
<div id="customLoginMain">
<table>
<tr id="customLoginHeader">
<td colspan="2" align="center"><b>Grampian Guidance Login</b></td>
</tr>
<tr>
<td nowrap="nowrap">
<SharePoint:EncodedLiteral runat="server" text="User Name" EncodeMethod='HtmlEncode' />
</td>
<td width="100%">
<asp:TextBox ID="UserName" autocomplete="off" runat="server" class="ms-inputuserfield userNameIcom" Width="94%" />
</td>
</tr>
<tr>
<td nowrap="nowrap">
<SharePoint:EncodedLiteral runat="server" text="Password" EncodeMethod='HtmlEncode' />
</td>
<td width="100%">
<asp:TextBox ID="Password" TextMode="Password" autocomplete="off" runat="server" class="ms-inputuserfield passwordIcom" Width="94%" /></td>
</tr>
<div class="ForgotPassword"><asp:HyperLink ID="hypforget" Text="Forgot Your Password?" Visible="false" runat="server" /></div>
<div class="ErrorMessage"><asp:Label ID="Label1" runat="server" Text="Label" Visible="false"></asp:Label></div>
<tr>
<td colspan="2" align="center">
<asp:checkbox id="rememberme" text="Remember Me" runat="server" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="LoginButton" runat="server" CommandName="Login"
Text="Login" onloggingin="OnLoggingIn" />
</td>
</tr>
</table>
</td>
</tr>
</table>
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.IdentityModel.Pages;
using System.Web;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Administration;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.IdentityModel;
namespace GG.Login.Custom.Layouts.GG.Login.Custom
{
public partial class Login : FormsSignInPage
{
Label lblError = new Label();
public object ScriptManager { get; private set; }
protected string UserIP { get { return HttpContext.Current.Request.UserHostAddress; } }
public object LblError { get; private set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
//protected void Login_Click(object sender, EventArgs e)
protected void OnLoggingIn(object sender, LoginCancelEventArgs e)
{
try
{
if (!(signInControl.UserName.Length > 0 && signInControl.Password.Length > 0))
{
lblError.Visible = true;
//lblError.Text = "STOP";
lblError.Text = "User Name or Password can not be empty!";
//lblError.BoldFont = true;
//FailureText.Text = "User Name or Password can not be empty!";
}
else
{
bool status = Microsoft.SharePoint.IdentityModel.SPClaimsUtility.AuthenticateFormsUser(Context.Request.UrlReferrer, signInControl.UserName, signInControl.Password);
if (!status)// if forms auth failed
{
lblError.Visible = true;
lblError.Text = "Wrong Userid or Password";
//FailureText.Visible = true;
//FailureText.Text = "Wrong Userid or Password";
}
else //if success
{
if (Context.Request.QueryString.Keys.Count > 1)
{
Response.Redirect(Context.Request.QueryString["Source"].ToString());
}
else
Response.Redirect(Context.Request.QueryString["ReturnUrl"].ToString());
lblError.Visible = false;
// Response.Redirect(SPContext.Current.Web.Url); //Use site url
}
}
}
catch (Exception ex)
{
ex.ToString();
}
}
void setupProvider()
{
if (null != SPContext.Current && null != SPContext.Current.Site)
{
SPIisSettings iisSettings = SPContext.Current.Site.WebApplication.IisSettings[SPUrlZone.Default];
if (null != iisSettings && iisSettings.UseWindowsClaimsAuthenticationProvider)
{
SPAuthenticationProvider provider = iisSettings.WindowsClaimsAuthenticationProvider;
RedirectToLoginPage(provider);
}
}
}
//borrowed from Microsoft.SharePoint.IdentityModel.LogonSelector
private void RedirectToLoginPage(SPAuthenticationProvider provider)
{
string components = HttpContext.Current.Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped);
string url = provider.AuthenticationRedirectionUrl.ToString();
if (provider is SPWindowsAuthenticationProvider)
{
components = EnsureUrlSkipsFormsAuthModuleRedirection(components, true);
}
SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
}
//borrowed from Microsoft.SharePoint.Utilities.SPUtility
private string EnsureUrlSkipsFormsAuthModuleRedirection(string url, bool urlIsQueryStringOnly)
{
if (!url.Contains("ReturnUrl="))
{
if (urlIsQueryStringOnly)
{
url = url + (string.IsNullOrEmpty(url) ? "" : "&");
}
else
{
url = url + ((url.IndexOf('?') == -1) ? "?" : "&");
}
url = url + "ReturnUrl=";
}
return url;
}
}
}