I've a problem to load Google Recaptcha control when I try to assign Public & Private Keys dynamically in code behind. It works fine in simple ASP.Net website but It doesn't work when I integrate it in DNN module.
Error Message: reCAPTCHA needs to be configured with a public & private key.
Stack trace:
DotNetNuke.Services.Exceptions.PageLoadException: reCAPTCHA needs to be configured with a public & private key. ---> System.ApplicationException: reCAPTCHA needs to be configured with a public & private key. at Recaptcha.RecaptchaControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at DotNetNuke.UI.Modules.ModuleHost.InjectModuleContent(Control content) at DotNetNuke.UI.Modules.ModuleHost.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
Markup:
<googleCaptcha:RecaptchaControl ID="ctlRecaptcha" runat="server" />
Code-behind:
protected void Page_Load(object sender, EventArgs e)
{
ctlRecaptcha.PublicKey = "xyz";
ctlRecaptcha.PrivateKey = "abc";
}
I actually have a tutorial on DNNHero.com that teaches on creating a custom DNN registration with the Google Recaptcha. It includes a video and code project.
Looking at my code, I included the attributes for publickey and privatekey on my ascx, but with dummy values:
<googleCaptcha:RecaptchaControl ID="ctlRecaptcha" runat="server" PublicKey="your_public_key" PrivateKey="your_private_key"/>
I set the attribute values like you did in my Page_Load event. This worked for me. Give it a try and comment if it still throw the error.
Related
I my share point site I have one List named "People List" and one Wiki Page Library named "People". I have created one visual webpart to display data from People list. I have created webpart property to read listname.The webpart property name for my visual webpart is "People". When I check whether list exists in my site using the following function it returns true:-
public static bool isListExists(SPWeb spWeb, string listName)
{
return spWeb.Lists.TryGetList(listName) != null;
}
But there is no List named "People" exists in my site. Only wiki page library named "People" exists. When I added my webpart in "MySite/People/default.aspx" page I got error.
Column 'Title' does not exist. It may have been deleted by another user.
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.ArgumentException: Column 'Title' does not exist. It may have been deleted by another user.
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:
[ArgumentException: Column 'Title' does not exist. It may have been deleted by another user.]
Microsoft.SharePoint.SPFieldCollection.GetField(String strName, Boolean bThrowException) +26422968
Microsoft.SharePoint.SPListItem.GetValue(String strName, Boolean bThrowException) +47
Microsoft.SharePoint.SPListItem.get_Item(String fieldName) +12
CL.DanceStudio.Portal.CLDance_Instructor.<>c__DisplayClass3.<Select>b__1() +1155
Microsoft.SharePoint.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2() +729
Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) +27491206
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) +27194345
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) +93
CL.DanceStudio.Portal.CLDance_Instructor.CLDance_InstructorUserControl.Select() +291
CL.DanceStudio.Portal.CLDance_Instructor.CLDance_InstructorUserControl.Page_Load(Object sender, EventArgs e) +52
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Control.AddedControl(Control control, Int32 index) +350
CL.DanceStudio.Portal.CLDance_Instructor.CLDance_Instructor.CreateChildControls() +194
System.Web.UI.Control.EnsureChildControls() +146
System.Web.UI.Control.PreRenderRecursiveInternal() +61
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Control.PreRenderRecursiveInternal() +224
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394
I think it is due to name conflict. Please provide me a solution.
I am creating RadTreeView nodes dynamically and I have created it successfully.But When I try to Add a sub-category node to it,sub-category is added successfully but at the end when I am reloading tree I am getting this error:
Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.Web.UI.RadComboBox.OnInit(EventArgs e) +40
System.Web.UI.Control.InitRecursive(Control namingContainer) +134
System.Web.UI.Control.AddedControl(Control control, Int32 index) +191
System.Web.UI.ControlCollection.Add(Control child) +86
Telerik.Web.UI.GridPagerItem.InitializePagerItem(GridColumn[] columns) +23849
Telerik.Web.UI.GridPagerItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows) +170
Telerik.Web.UI.GridTableView.CreateTopPagerItem(Boolean useDataSource, GridColumn[] copiedColumnSet, Boolean isPagingEnabled, GridTHead thead) +93
Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1156
Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +679
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +149
System.Web.UI.Control.EnsureChildControls() +83
Telerik.Web.UI.GridTableViewBase.get_Controls() +15
Telerik.Web.UI.GridTableView.GetGridTable() +15
Telerik.Web.UI.RadGrid.PrepareRowsVisibility(GridTableView view) +33
Telerik.Web.UI.RadGrid.PrepareItems() +308
Telerik.Web.UI.RadGrid.ControlPreRender() +64
Telerik.Web.UI.RadCompositeDataBoundControl.OnPreRender(EventArgs e) +41
System.Web.UI.Control.PreRenderRecursiveInternal() +83
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974
Dont understand this I tried to debug my code using debug point but everthing is executed alright but at the end I am getting this error.
yes after a long research on my code I got the answer that my grid was getting referenced to null.But its very sad that this is such a famous forum but no one was able to understand the stack trace.
I had this issue after a postback with a radgrid, the problem was the Datasourse was null. To fix it you only have to set DataSource = ""
I am currently trying to help a client limp along with a very old .NET application written with C# and aspx. .NET and C# are not my primary, 2nd or even 3rd technologies I typically work with so my knowledge of them is rather limited.
The big problem is that we do not have the source code for the C# side of the application and the only thing we can look at or even edit is the aspx files.
We have a page that is giving us the following error:
Sequence contains more than one matching element
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.InvalidOperationException: Sequence contains more than one matching element
Source Error:
Line 54: <asp:DataList ID="dlChoice" runat="server" DataSource='<%# GetChoices(Convert.ToInt32(Eval("QuestionId"))) %>' RepeatColumns="3" RepeatDirection="Horizontal" RepeatLayout="Table" EnableViewState="false">
Line 55: <ItemTemplate>
Line 56: <span id='s<%# Eval("ChoiceId") %>' class='<%# GetChoiceStyle(Convert.ToInt32(Eval("ChoiceId"))) %>'><%# GetTextBoxes(Convert.ToInt32(Eval("QuestionId")), Convert.ToInt32(Eval("ChoiceId")),Convert.ToString(Eval("Points"))) %> <%# ReplaceToken(Eval("ChoiceText").ToString()) %></span>
Line 57: </ItemTemplate>
Line 58: </asp:DataList>
Source File: e:\inetpub\webapp\ScoringSheet.aspx Line: 56
Stack Trace:
[InvalidOperationException: Sequence contains more than one matching element]
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source, Func`2 predicate) +1304639
lambda_method(ExecutionScope ) +97
System.Linq.EnumerableExecutor`1.Execute() +244
System.Linq.EnumerableQuery`1.System.Linq.IQueryProvider.Execute(Expression expression) +154
System.Linq.Queryable.SingleOrDefault(IQueryable`1 source, Expression`1 predicate) +422
CPAT.ScoringSheet.GetChoiceStyle(Int32 choiceId) +298
ASP.scoringsheet_aspx.__DataBind__control11(Object sender, EventArgs e) in e:\inetpub\webapp\ScoringSheet.aspx:56
System.Web.UI.Control.OnDataBinding(EventArgs e) +132
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +170
System.Web.UI.Control.DataBindChildren() +11045679
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +182
System.Web.UI.WebControls.DataList.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +175
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +734
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +89
System.Web.UI.Control.DataBindChildren() +11045679
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +182
System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +674
System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +68
System.Web.UI.Control.DataBindChildren() +11045679
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +182
System.Web.UI.WebControls.ListView.CreateItemsWithoutGroups(ListViewPagedDataSource dataSource, Boolean dataBinding, InsertItemPosition insertPosition, ArrayList keyArray) +924
System.Web.UI.WebControls.ListView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +838
System.Web.UI.WebControls.ListView.PerformDataBinding(IEnumerable data) +46
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +147
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +261
System.Web.UI.WebControls.ListView.PerformSelect() +74
CPAT.ScoringSheet.Page_Load(Object sender, EventArgs e) +3500
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
Version Information: Microsoft .NET Framework Version:2.0.50727.5420; ASP.NET Version:2.0.50727.5420
My question: how can I add enough error handling to show a nice little error message where the offending tag is located but allow the rest of the page to render? This would allow me to see exactly what part of the data set is having problems. I suspect there is something amiss in the database (duplicate record, bad data, etc.) but I can't find or see the query that is running nor what data is breaking the page.
I tried adding various try / catch blocks but I suspect these data binds are run separately somehow and the try / catch I added are just ignored and the page still errors.
The issue seems to be happening inside the method CPAT.ScoringSheet.GetChoiceStyle(Int32 choiceId) Specifically there seems to be a SingleOrDefault call in there on the linq query that will fail if there is more than one element for the given input.
If this is not a valid condition I would check the data and fix it in the data. Otherwise you will have to change the code inside said method to allow more elements.
I am using membership and have created a custom profile that contains a property called FirstName. It works well except when the session/cookies are lost (I haven't figured out exactly which since it's pretty hard to reproduce). Then when I access any page of the site I get this exception:
[SettingsPropertyNotFoundException: The settings property 'FirstName' was not
found.]
System.Configuration.SettingsBase.GetPropertyValueByName(String
propertyName) +8757578
System.Configuration.SettingsBase.get_Item(String propertyName) +118
System.Web.Profile.ProfileBase.GetInternal(String propertyName) +49
System.Web.Profile.ProfileBase.get_Item(String propertyName) +129
WebFrontend.Security.SecurityHandler.get_FullName() +168
WebFrontend.Controls.LoginInfo.SetupLoginStatus() +15
System.Web.UI.Control.InitRecursive(Control namingContainer) +186
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint) +2098
Do you have any idea how I can stop this exception from being thrown? Also CustomErrors are ON for this site and it bypasses the error page, instead it shows the exception. I just want to prevent the users from seeing this ugly exception.
It sounds like you are attempting to access the users profile when they are no longer authenticated. I would reccomend that you consider implementing a Login View OR checking for authentication before accessing the users profile properties:
Login View: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginview.anonymoustemplate(v=vs.100).aspx
Check Authentication: http://msdn.microsoft.com/en-us/library/system.web.httprequest.isauthenticated(v=vs.90).aspx
I am caching a fairly large datatable into the application cache using:
HttpContext.Current.Cache.Insert(GlobalVars.Current.applicationID + "_" + cacheName, itemToCache, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(240));
As you can see, it should stay in the cache for 4 hours, however we are seeing strange results:
On a site with low CPU & low RAM usage (say 0-150 users) we receive no errors.
On a site with high CPU and low RAM usage (CPU ~90%, 300 - 600 users), we get the following error every 20-60mins:
Cannot find column EditorOrder.
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IndexOutOfRangeException: Cannot find column EditorOrder.
at System.Data.DataTable.ParseSortString(String sortString)
at System.Data.DataView.set_Sort(String value)
at delima_v1._01.templates.results.editors_picks.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
EditorOrder is a column that is added manually to the datatable once the results have been taken from SQL. So i'm unsure if the column is somehow being removed or the entire cache is being lost, the error seems to indicate it's the column being lost. As I said, it only seems to be under high loads so unsure as to whether IIS/Windows have any effect....
Site is running ASP.NET 4.0 in 64bit AppPool
Many thanks in advance,
Dave