MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

FOREIGN KEY CONTRAINT issue  (Mono Support )

Viewed 30616 time(s), 4 post(s) 6/5/2014 2:50:20 PMby Zoomicon
Zoomicon

Zoomicon

6/5/2014 2:50:20 PM

An admin user tried to post a blog post and show error:
</br>
</br>An exception was caught during the execution of an action query: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPost_aspnet_Users". The conflict occurred in database "MonoX2", table "dbo.aspnet_Users", column 'UserId'. The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

then realized they were logged out, logged in again and from what I understand managed to post OK

----

this doesn't sound OK. I'd expect the ASP.net postback code of yours at page used to submit the blog post to check (say if the session has timedout) that the user is logged in and has appropriate role to complete the request, before trying to touch the database. Else it can be a security error (if somebody finds a way to exploit this on a shared computer or maybe even remotely somehow), apart from the issue that it could maybe lead to db corruption by accident (and the user experience issue of course)

--- here is what was logged:
</br>
</br>2014-06-05 16:45:44,861 [104] ERROR MonoX [stavr] - Thread was being aborted.
</br>   at System.Threading.Thread.AbortInternal()
</br>   at System.Threading.Thread.Abort(Object stateInfo)
</br>   at System.Web.HttpResponse.AbortCurrentThread()
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogContainer.#yp(Object sender, EventArgs e)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogPostEdit.btnSave_Click(Object sender, EventArgs e)

2014-06-05 16:45:44,970 [STP SmartThreadPool Thread #0] WARN  MonoX [stavr] - Exception has been thrown by the target of an invocation.
</br>2014-06-05 16:45:49,712 [STP SmartThreadPool Thread #1] ERROR MonoX [271ec6af-621f-4b1a-bfcf-f764ecb3e1bd] - The operation has timed out
</br>   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
</br>   at System.Net.HttpWebRequest.GetRequestStream()
</br>   at MonoSoftware.MonoX.Blog.Ping.#Kj(HttpWebRequest request, String websiteName, String websiteUrl)
</br>   at MonoSoftware.MonoX.Blog.Ping.Send(String websiteName, String websiteUrl)

2014-06-05 16:53:13,346 [STP SmartThreadPool Thread #0] WARN  MonoX [stavr] - Exception has been thrown by the target of an invocation.
</br>2014-06-05 16:53:13,361 [98] ERROR MonoX [stavr] - Thread was being aborted.
</br>   at System.Threading.Thread.AbortInternal()
</br>   at System.Threading.Thread.Abort(Object stateInfo)
</br>   at System.Web.HttpResponse.AbortCurrentThread()
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogContainer.#yp(Object sender, EventArgs e)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogPostEdit.btnSave_Click(Object sender, EventArgs e)

2014-06-05 16:53:17,854 [STP SmartThreadPool Thread #1] ERROR MonoX [152c3514-eef6-4c00-ba56-2ee328e7b6b2] - The operation has timed out
</br>   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
</br>   at System.Net.HttpWebRequest.GetRequestStream()
</br>   at MonoSoftware.MonoX.Blog.Ping.#Kj(HttpWebRequest request, String websiteName, String websiteUrl)
</br>   at MonoSoftware.MonoX.Blog.Ping.Send(String websiteName, String websiteUrl)

2014-06-05 16:57:39,061 [86] ERROR MonoX [157.55.39.25] - Error
</br>System.Security.SecurityException: Security error.
</br>   at MonoSoftware.MonoX.BasePage.OnInit(EventArgs e)
</br>   at System.Web.UI.Control.InitRecursive(Control namingContainer)
</br>   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
</br>The Zone of the assembly that failed was:
</br>MyComputer
</br>2014-06-05 17:07:56,729 [104] ERROR MonoX [27.157.91.46] - Error
</br>System.ArgumentException: String cannot be of zero length.
</br>Parameter name: oldValue
</br>   at System.String.ReplaceInternal(String oldValue, String newValue)
</br>   at MonoSoftware.MonoX.Utilities.UrlUtility.RewritePagePath(String urlToRewrite, String callerUrl)
</br>   at MonoSoftware.MonoX.Utilities.UrlUtility.RewritePagePath(String urlToRewrite, Object formatSource)
</br>   at MonoSoftware.MonoX.RewrittenUrlBuilder.Blog.GetBlogPostUrl(String urlPattern, BlogPostEntity blogPost, String callerPage)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BaseBlogPart.FormatBlogPostUrl(BlogPostEntity post)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BaseBlogFormattedDisplayPart.ParseBlogPostTemplateTags(BlogPostEntity post, Int32 maxTitleChars, Int32 maxDescriptionChars, String dateFormatString)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogPostList.lvItems_OnItemDataBound(Object sender, ListViewItemEventArgs e)
</br>   at System.Web.UI.WebControls.ListView.OnItemDataBound(ListViewItemEventArgs e)
</br>   at System.Web.UI.WebControls.ListView.CreateItemsWithoutGroups(ListViewPagedDataSource dataSource, Boolean dataBinding, InsertItemPosition insertPosition, ArrayList keyArray)
</br>   at System.Web.UI.WebControls.ListView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding)
</br>   at System.Web.UI.WebControls.ListView.PerformDataBinding(IEnumerable data)
</br>   at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
</br>   at System.Web.UI.WebControls.ListView.PerformSelect()
</br>   at MonoSoftware.MonoX.Utilities.PagerUtility.BindPager(Pager pager, PagerAction bindDelegate, Control pagedControl, Object dataSource, Int32 pagerVirtualCount, Control warningControl)
</br>   at MonoSoftware.MonoX.Utilities.PagerUtility.BindPager(Pager pager, PagerAction bindDelegate, Control pagedControl, Object dataSource, Int32 pagerVirtualCount)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogPostList.BindData()
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogPostList.OnLoad(EventArgs e)
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Control.LoadRecursive()
</br>   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
</br>2014-06-05 17:19:49,275 [19] ERROR MonoX [150.140.11.42] - An exception was caught during the execution of an action query: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPost_aspnet_Users". The conflict occurred in database "MonoX2", table "dbo.aspnet_Users", column 'UserId'.
</br>The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Execute()
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteActionQuery(IActionQuery queryToExecute)
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(List`1 queueToPersist, Boolean insertActions, Int32& totalAmountSaved)
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse)
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave)
</br>   at MonoSoftware.LLBLGen.Repository.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave)
</br>   at MonoSoftware.MonoX.Repositories.BlogRepository.EnsurePostExists(Guid postId)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogPostEdit.btnSave_Click(Object sender, EventArgs e)

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPost_aspnet_Users". The conflict occurred in database "MonoX2", table "dbo.aspnet_Users", column 'UserId'.
</br>The statement has been terminated.
</br>   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
</br>   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
</br>   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
</br>   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
</br>   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
</br>   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
</br>   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
</br>   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()

2014-06-05 17:19:55,437 [67] ERROR MonoX [150.140.11.42] - An exception was caught during the execution of an action query: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPost_aspnet_Users". The conflict occurred in database "MonoX2", table "dbo.aspnet_Users", column 'UserId'.
</br>The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Execute()
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteActionQuery(IActionQuery queryToExecute)
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(List`1 queueToPersist, Boolean insertActions, Int32& totalAmountSaved)
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse)
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave)
</br>   at MonoSoftware.LLBLGen.Repository.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave)
</br>   at MonoSoftware.MonoX.Repositories.BlogRepository.EnsurePostExists(Guid postId)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogPostEdit.btnSave_Click(Object sender, EventArgs e)

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPost_aspnet_Users". The conflict occurred in database "MonoX2", table "dbo.aspnet_Users", column 'UserId'.
</br>The statement has been terminated.
</br>   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
</br>   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
</br>   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
</br>   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
</br>   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
</br>   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
</br>   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
</br>   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()

2014-06-05 17:20:09,805 [88] ERROR MonoX [150.140.11.42] - An exception was caught during the execution of an action query: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPost_aspnet_Users". The conflict occurred in database "MonoX2", table "dbo.aspnet_Users", column 'UserId'.
</br>The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Execute()
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteActionQuery(IActionQuery queryToExecute)
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(List`1 queueToPersist, Boolean insertActions, Int32& totalAmountSaved)
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse)
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave)
</br>   at MonoSoftware.LLBLGen.Repository.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave)
</br>   at MonoSoftware.MonoX.Repositories.BlogRepository.EnsurePostExists(Guid postId)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogPostEdit.btnSave_Click(Object sender, EventArgs e)

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_BlogPost_aspnet_Users". The conflict occurred in database "MonoX2", table "dbo.aspnet_Users", column 'UserId'.
</br>The statement has been terminated.
</br>   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
</br>   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
</br>   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
</br>   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
</br>   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
</br>   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
</br>   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
</br>   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
</br>   at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()

2014-06-05 17:21:59,894 [STP SmartThreadPool Thread #0] WARN  MonoX [stavr] - Exception has been thrown by the target of an invocation.
</br>2014-06-05 17:21:59,894 [103] ERROR MonoX [stavr] - Thread was being aborted.
</br>   at System.Threading.Thread.AbortInternal()
</br>   at System.Threading.Thread.Abort(Object stateInfo)
</br>   at System.Web.HttpResponse.AbortCurrentThread()
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogContainer.#yp(Object sender, EventArgs e)
</br>   at MonoSoftware.MonoX.ModuleGallery.Blog.BlogPostEdit.btnSave_Click(Object sender, EventArgs e)

2014-06-05 17:22:04,902 [STP SmartThreadPool Thread #1] ERROR MonoX [b0178d88-fab1-4d35-8523-a11533186ef1] - The operation has timed out
</br>   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
</br>   at System.Net.HttpWebRequest.GetRequestStream()
</br>   at MonoSoftware.MonoX.Blog.Ping.#Kj(HttpWebRequest request, String websiteName, String websiteUrl)
</br>   at MonoSoftware.MonoX.Blog.Ping.Send(String websiteName, String websiteUrl)

This content has not been rated yet. 
2793 Reputation 345 Total posts
dbracun

dbracun

6/6/2014 8:47:22 AM
Hi,
Please add following code to BlogPostEdit.ascx.cs on OnInit event to check if user is authenticated:

 if (!SecurityUtility.IsAuthenticated())
                throw new SecurityException();

Regards
This content has not been rated yet. 
188 Reputation 18 Total posts
Zoomicon

Zoomicon

6/6/2014 11:23:35 AM

Will you be adding it to MonoX nightly build?

I don't have access to the source code

This content has not been rated yet. 
2793 Reputation 345 Total posts
vzakanj

vzakanj

6/17/2014 9:57:44 AM
Hi Zoomicon,
just letting you know that this issue has been logged to the internal bug tracker and will be resolved in one of the next nightly builds.

Regards,
Vedran
This content has not been rated yet. 
345 Reputation 61 Total posts