KaranGupta
asked on
Sys.WebForms.PageRequestManagerServerErrorException:
Hi
I have created a Ajax enabled website. When I click on submit button I am getting a popup message.
"Sys.WebForms.PageRequestM anagerServ erErrorExc eption:An unknown error occured while processing the request on the server.The status code returned from the server was:500
"
I searched through the net and do this change in web.config file
<pages validateRequest="false">
But still I am getting the same error.
Regards
Karan Gupta
I have created a Ajax enabled website. When I click on submit button I am getting a popup message.
"Sys.WebForms.PageRequestM
"
I searched through the net and do this change in web.config file
<pages validateRequest="false">
But still I am getting the same error.
Regards
Karan Gupta
ASKER
HI
Is it ok if I do it in web.config.
Regards
Karan Gupta
Is it ok if I do it in web.config.
Regards
Karan Gupta
ASKER
HI
I have changed in the web.config file.But I am still getting the same error.
The error is not coming on my local machine, but when I upload the code after publishing to the server then I am getting this error.
Regards
Karan Gupta
I have changed in the web.config file.But I am still getting the same error.
The error is not coming on my local machine, but when I upload the code after publishing to the server then I am getting this error.
Regards
Karan Gupta
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi KaranGupta,
Possible post some of the existing related code for further inspection?
Possible post some of the existing related code for further inspection?
ASKER
Hi
I am uploading the .aspx code.
Regards
Karan Gupta
I am uploading the .aspx code.
Regards
Karan Gupta
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RegistrationPage.aspx.cs"
Inherits="RegistrationPage" MaintainScrollPositionOnPostback="true" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxToolKit" %>
<%@ Register Assembly="CaptchaUltimateCustomControl" Namespace="PeterKellner.Utils"
TagPrefix="CAPTCHA" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Registration Page</title>
</head>
<body>
<form id="frmRegistrationPage" runat="server" defaultfocus="txtName" defaultbutton="btnCreateUser">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div style="visibility: hidden; width: 0px; height: 0px;">
<!--Custom Validator for Name-->
<asp:CustomValidator Visible="true" ID="cvName" runat="server" ControlToValidate="txtName"
Enabled="true" ValidateEmptyText="true" OnServerValidate="ValidateName" Display="dynamic"></asp:CustomValidator>
<asp:CustomValidator Visible="true" ID="cvSigninID" runat="server" ControlToValidate="txtSignInID"
Enabled="true" ValidateEmptyText="true" OnServerValidate="ValidateSigninID" Display="dynamic"></asp:CustomValidator>
<asp:CustomValidator Visible="true" ID="cvPassword" runat="server" ControlToValidate="txtPassword"
Enabled="true" ValidateEmptyText="true" OnServerValidate="ValidatePassword" Display="dynamic"></asp:CustomValidator>
<asp:CustomValidator Visible="true" ID="cvConfirmPassword" runat="server" ControlToValidate="txtConfirmPassword"
Enabled="true" ValidateEmptyText="true" OnServerValidate="ValidateConfirmPassword"
Display="dynamic"></asp:CustomValidator>
<asp:CustomValidator Visible="true" ID="cvPhoneNumber" runat="server" ControlToValidate="txtPhoneNumber"
Enabled="true" ValidateEmptyText="true" OnServerValidate="ValidatePhoneNumber"
Display="dynamic"></asp:CustomValidator>
<asp:CustomValidator Visible="true" ID="cvMobileNumber" runat="server" ControlToValidate="txtMobileNumber"
Enabled="true" ValidateEmptyText="true" OnServerValidate="ValidateMobileNumber"
Display="dynamic"></asp:CustomValidator>
<asp:CustomValidator Visible="true" ID="cvEmail" runat="server" ControlToValidate="txtEmailID"
Enabled="true" ValidateEmptyText="true" OnServerValidate="ValidateEmailID" Display="dynamic"></asp:CustomValidator>
<asp:CustomValidator Visible="true" ID="cvAddress" runat="server" ControlToValidate="txtAddress"
Enabled="true" ValidateEmptyText="true" OnServerValidate="ValidateAddress" Display="dynamic"></asp:CustomValidator>
<asp:CustomValidator Visible="true" ID="cvCode" runat="server" Enabled="true" ValidateEmptyText="true"
OnServerValidate="ValidateCode" Display="dynamic"></asp:CustomValidator>
</div>
<table align="center">
<tr>
<td colspan="2" align="left">
<asp:ValidationSummary ID="validationSummary" DisplayMode="BulletList" EnableClientScript="true"
ShowSummary="true" runat="server" />
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:Label ID="lblHeading" runat="server" CssClass="PageHeading" Text="Registration Page"
EnableViewState="false"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblName" runat="server" Text="Name" EnableViewState="false"></asp:Label>
<span>:</span>
</td>
<td align="left">
<asp:TextBox ID="txtName" runat="server" Width="200px" MaxLength="100"></asp:TextBox>
<span><font color="red">*</font></span>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblSignInID" runat="server" Text="Sign In ID" EnableViewState="false"></asp:Label>
<span>:</span>
</td>
<td align="left">
<asp:TextBox ID="txtSignInID" runat="server" Width="200px" MaxLength="100"></asp:TextBox>
<span><font color="red">*</font></span>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblPassword" runat="server" Text="Password" EnableViewState="false"></asp:Label>
<span>:</span>
</td>
<td align="left">
<asp:TextBox ID="txtPassword" TextMode="Password" runat="server" Width="200px" MaxLength="100"></asp:TextBox>
<span><font color="red">*</font></span>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblConfirmPassword" runat="server" Text="Confirm Password" EnableViewState="false"></asp:Label>
<span>:</span>
</td>
<td align="left">
<asp:TextBox ID="txtConfirmPassword" TextMode="Password" runat="server" Width="200px"
MaxLength="100"></asp:TextBox>
<span><font color="red">*</font></span>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblPhoneNumber" runat="server" Text="Phone Number" EnableViewState="false"></asp:Label>
<span>:</span>
</td>
<td align="left">
<asp:TextBox ID="txtPhoneNumber" runat="server" Width="200px" MaxLength="100"></asp:TextBox>
<span><font color="red">*</font></span>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblMobileNumber" runat="server" Text="Mobile Number" EnableViewState="false"></asp:Label>
<span>:</span>
</td>
<td align="left">
<asp:TextBox ID="txtMobileNumber" runat="server" Width="200px" MaxLength="100"></asp:TextBox>
<span><font color="red">*</font></span>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblEmailID" runat="server" Text="Email ID" EnableViewState="false"></asp:Label>
<span>:</span>
</td>
<td align="left">
<asp:TextBox ID="txtEmailID" runat="server" Width="200px" MaxLength="100"></asp:TextBox>
<span><font color="red">*</font></span>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="lblAddress" runat="server" Text="Address" EnableViewState="false"></asp:Label>
<span>:</span>
</td>
<td align="left">
<asp:TextBox ID="txtAddress" TextMode="MultiLine" runat="server" Width="200px" MaxLength="100"></asp:TextBox>
<span><font color="red">*</font></span>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="right" valign="top">
<asp:Label ID="lblSecurityCode" runat="server" Text="Security Code" EnableViewState="false"></asp:Label>
<span>:</span>
</td>
<td align="left" valign="bottom">
<CAPTCHA:CaptchaUltimateControl ID="CaptchaUltimateControl1" runat="server" ButtonRedisplayCaptchaText="Generate New Display Number"
CaptchaBackgroundColor="White" CaptchaBorder="1" CaptchaLength="4" CaptchaType="2"
CommandArg1="" CommandArg2="" CommandArg3="" CommandArg4="" CommandArg5="" EncryptedValue=""
FontFamilyString="Courrier New" HeightCaptchaPixels="50" InvalidCaptchaMessage=""
PlainValue="" ShowPromo="false" ShowRecalculateCaptchaButton="True" ShowTitle="false"
Title="Captcha Control" WidthCaptchaPixels="140">
<ItemTemplate>
<table id="Table1" runat="server" border="0" cellpadding="0" cellspacing="0">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<asp:TextBox ID="VerificationID" Width="200px" runat="server" MaxLength="10"></asp:TextBox>
<span><font color="red">*</font></span>
</td>
</tr>
<tr id="Tr2" runat="server">
<td id="Td2" runat="server" colspan="2" style="text-align: center;">
<asp:Image ID="CaptchaImageID" runat="server" ImageUrl="~/CaptchaType.ashx" />
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td3" runat="server" colspan="2" style="text-align: center;">
<asp:Button ID="ButtonDisplayNextID" runat="server" Text="Generate New Display Number" />
</td>
</tr>
</table>
</ItemTemplate>
</CAPTCHA:CaptchaUltimateControl>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnCreateUser" Text="Create User" runat="server" OnClick="btnCreateUser_Click" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Label ID="lblErrorMessage" runat="server"></asp:Label>
</td>
</tr>
</table>
<AjaxToolKit:ModalPopupExtender ID="MPEMessage" runat="server" TargetControlID="lblMessage"
OkControlID="btnOK" PopupControlID="pnlMessage">
</AjaxToolKit:ModalPopupExtender>
<asp:Panel ID="pnlMessage" Height="158" Width="261" runat="server" BackImageUrl="~/images/Alert.GIF"
Style="background-repeat: no-repeat;">
<table height="100%" width="100%">
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="btnOK" runat="server" Text="Ok" />
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnCreateUser" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<script language="javascript" type="text/javascript">
function pageLoad()
{
var popup = $find('<%= MPEMessage.ClientID %>');
popup.add_shown(SetFocus);
}
function SetFocus()
{
$get('btnOK').focus();
}
</script>
</form>
</body>
</html>
Hi KaranGupta,
Ok, try turn off validateRequest and EnableEventValidation under this page's directive.
Check if the problem still persist.
eg:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RegistrationPage .aspx.cs"
Inherits="RegistrationPage " MaintainScrollPositionOnPo stback="tr ue" EnableEventValidation="fal se" ValidateRequest="false" %>
Ok, try turn off validateRequest and EnableEventValidation under this page's directive.
Check if the problem still persist.
eg:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RegistrationPage
Inherits="RegistrationPage
ASKER
Hi
I have turned off validateRequest and EnableEventValidation in page's directive but still I am getting same error.
Is there anything related to code behind.
Regards
Karan Gupta
I have turned off validateRequest and EnableEventValidation in page's directive but still I am getting same error.
Is there anything related to code behind.
Regards
Karan Gupta
ASKER
Hi
Any updates.
Regards
Karan Gupta
Any updates.
Regards
Karan Gupta
Hi KaranGupta,
Can you post the code-behind and the error line of code that hit the issue?
Can you post the code-behind and the error line of code that hit the issue?
ASKER
Hi
Here is the code
Regards
Karan Gupta
Here is the code
Regards
Karan Gupta
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
public partial class RegistrationPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ValidateName(object sender, ServerValidateEventArgs args)
{
// Declare
GeneralFunctions oGeneralFunctions;
// Initialize
oGeneralFunctions = new GeneralFunctions();
if (string.IsNullOrEmpty(txtName.Text.Trim()))
{
args.IsValid = false;
cvName.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_NAME_EMPTY_VALIDATION"];
}
else if (!oGeneralFunctions.IsName(txtName.Text.Trim()))
{
args.IsValid = false;
cvName.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_INVALIDNAME"];
}
}
protected void ValidateSigninID(object sender, ServerValidateEventArgs args)
{
// Declaration
B_RegistrationPage oB_RegistrationPage;
// Initialization
oB_RegistrationPage = new B_RegistrationPage();
if (string.IsNullOrEmpty(txtSignInID.Text.Trim()))
{
args.IsValid = false;
cvSigninID.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_SIGNINID_EMPTY_VALIDATION"];
}
else if(oB_RegistrationPage.IsSignInIdExists(txtSignInID.Text.Trim()))
{
args.IsValid = false;
cvSigninID.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_SIGNINID_ID_ALREADY_EXISTS"];
}
}
protected void ValidatePassword(object sender, ServerValidateEventArgs args)
{
if (string.IsNullOrEmpty(txtPassword.Text.Trim()))
{
args.IsValid = false;
cvPassword.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_PASSWORD_EMPTY_VALIDATION"];
}
}
protected void ValidateConfirmPassword(object sender, ServerValidateEventArgs args)
{
if (string.IsNullOrEmpty(txtConfirmPassword.Text.Trim()))
{
args.IsValid = false;
cvConfirmPassword.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_CONFIRM_PASSWORD_EMPTY_VALIDATION"];
}
else if (txtPassword.Text != txtConfirmPassword.Text)
{
args.IsValid = false;
cvConfirmPassword.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_PASSWORD_AND_CONFFIRM_PASSWORD_NOT_SAME"];
}
}
protected void ValidatePhoneNumber(object sender, ServerValidateEventArgs args)
{
//Declaration
GeneralFunctions oGeneralFunctions;
// Initialization
oGeneralFunctions = new GeneralFunctions();
if (string.IsNullOrEmpty(txtPhoneNumber.Text.Trim()))
{
args.IsValid = false;
cvPhoneNumber.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_PHONE_NUMBER_EMPTY_VALIDATION"];
}
else if (!oGeneralFunctions.IsNumeric(txtPhoneNumber.Text.Trim()))
{
args.IsValid = false;
cvPhoneNumber.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_PHONE_NUMBER_INVALID"];
}
}
protected void ValidateMobileNumber(object sender, ServerValidateEventArgs args)
{
//Declaration
GeneralFunctions oGeneralFunctions;
// Initialization
oGeneralFunctions = new GeneralFunctions();
if (string.IsNullOrEmpty(txtMobileNumber.Text.Trim()))
{
args.IsValid = false;
cvMobileNumber.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_MOBILE_NUMBER_EMPTY_VALIDATION"];
}
else if (!oGeneralFunctions.IsNumeric(txtMobileNumber.Text.Trim()))
{
args.IsValid = false;
cvMobileNumber.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_MOBILE_NUMBER_INVALID"];
}
}
protected void ValidateEmailID(object sender, ServerValidateEventArgs args)
{
//Declaration
GeneralFunctions oGeneralFunctions;
// Initialization
oGeneralFunctions = new GeneralFunctions();
if (string.IsNullOrEmpty(txtEmailID.Text.Trim()))
{
args.IsValid = false;
cvEmail.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_EMAIL_EMPTY_VALIDATION"];
}
else if (!oGeneralFunctions.IsEmail(txtEmailID.Text.Trim()))
{
args.IsValid = false;
cvEmail.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_EMAIL_INVALID"];
}
}
protected void ValidateAddress(object sender, ServerValidateEventArgs args)
{
if (string.IsNullOrEmpty(txtAddress.Text.Trim()))
{
args.IsValid = false;
cvAddress.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_ADDRESS_EMPTY_VALIDATION"];
}
else if (txtAddress.Text.Trim().Length > Convert.ToInt32(ConfigurationManager.AppSettings["TEXTAREA_MAX_LENGTH"]))
{
args.IsValid = false;
cvAddress.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_ADDRESS_LENGTH"] + ConfigurationManager.AppSettings["TEXTAREA_MAX_LENGTH"];
}
}
protected void ValidateCode(object sender, ServerValidateEventArgs args)
{
TextBox txtVerificationID = (TextBox)CaptchaUltimateControl1.FindControl("VerificationID");
if (txtVerificationID.Text.Trim() == string.Empty)
{
args.IsValid = false;
cvCode.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_CODE_EMPTY_VALIDATION"];
}
else if (string.Compare(txtVerificationID.Text.Trim(), CaptchaUltimateControl1.PlainValue, false) != 0)
{
args.IsValid = false;
cvCode.ErrorMessage = ConfigurationManager.AppSettings["REGISTRATION_PAGE_CODE_NOT_SAME"];
}
}
protected void btnCreateUser_Click(object sender, EventArgs e)
{
// Declaration
B_RegistrationPage reg;
GeneralFunctions oGeneralFunctions;
// Initialization
reg = new B_RegistrationPage();
oGeneralFunctions = new GeneralFunctions();
// Validate Capcha
lblMessage.Text = string.Empty;
if (!Page.IsValid)
{
lblErrorMessage.ForeColor = Color.Red;
lblErrorMessage.Text = ConfigurationManager.AppSettings["REGISTRATION_PAGE_LABEL_ERROR_MESSAGE"];
return;
}
TextBox txtVerificationID = (TextBox)CaptchaUltimateControl1.FindControl("VerificationID");
// Assign the value to properties
reg.Name = txtName.Text.Trim();
reg.SignInID = txtSignInID.Text.Trim();
reg.Password = txtPassword.Text;
reg.PhoneNumber = txtPhoneNumber.Text.Trim();
reg.MobileNumber = txtMobileNumber.Text.Trim();
reg.Address = txtAddress.Text.Trim();
reg.EmailID = txtEmailID.Text.Trim();
// If all the validations are done then create user
reg.CreateUser();
// Confirmation Message
lblMessage.ForeColor = Color.Blue;
lblMessage.Text = ConfigurationManager.AppSettings["REGISTRATION_PAGE_CONFIRMATION_MESSAGE"];
MPEMessage.Show();
lblErrorMessage.ForeColor = Color.Blue;
lblErrorMessage.Text = ConfigurationManager.AppSettings["REGISTRATION_PAGE_REGISTRATION_COMPLETE"];
return;
}
}
Hi KaranGupta,
Can you specify the line of error code too? Lastly, try remove the "return"(last line) statement from "btnCreateUser_Click" event since this is a non-return sub routine.
Can you specify the line of error code too? Lastly, try remove the "return"(last line) statement from "btnCreateUser_Click" event since this is a non-return sub routine.
ASKER
Hi
Is that possible that we are getting these errors because of permission on the folder. I am using MS ACCESS database and that is placed in App_Data folder.
Regards
Karan Gupta
Is that possible that we are getting these errors because of permission on the folder. I am using MS ACCESS database and that is placed in App_Data folder.
Regards
Karan Gupta
Hi KaranGupta,
I'm not sure if the problem is mentioned related to permission issue. .The status code returned from the server was:500 is related to server error. I've noticed some of the code that posted not complete for "btnCreateUser_Click". I'm not sure if any server action that invoked inside is causing the error. Please post the related code snippet for further inspections.
This article can guide you some useful tips regarding error:500 in this case:
http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx
I'm not sure if the problem is mentioned related to permission issue. .The status code returned from the server was:500 is related to server error. I've noticed some of the code that posted not complete for "btnCreateUser_Click". I'm not sure if any server action that invoked inside is causing the error. Please post the related code snippet for further inspections.
This article can guide you some useful tips regarding error:500 in this case:
http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx
Try disable page's EnableEventValidation property.
eg:
<%@ Page Language="C#" .... EnableEventValidation="fal