Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 536675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:50:49+00:00 2026-05-13T09:50:49+00:00

I have a slightly modified AccountController that should write a row into a table

  • 0

I have a slightly modified AccountController that should write a row into a table upon login.

However, the page redirects before the DB action has completed and so nothing is inserted.

I’ve temporarily solved this by sticking in a Thread.Sleep, but I’m looking for an alternative that makes it appear seamless.

    If Not String.IsNullOrEmpty(returnUrl) Then
        Return Redirect(returnUrl)
    Else
        Dim db As New GlobalSecModelDataContext
        Dim logAdmin = New secAdminLog
        logAdmin.EmployeeNumber = userName
        logAdmin.What = "Logged in"
        logAdmin.DateLogged = DateTime.Now
        logAdmin.UserIP = Request.ServerVariables("REMOTE_ADDR")
        logAdmin.NetworkUser = Request.ServerVariables("REMOTE_USER")

        db.secAdminLogs.InsertOnSubmit(logAdmin)
        db.SubmitChanges()
        Session("LoggedInUser") = StrConv(userName, VbStrConv.ProperCase)
        Threading.Thread.Sleep(5000)
        Return Redirect("/Home")
    End If

Is there a better solution that would be quicker for the user using the system or is using Threading.Thread.Sleep(5000) the best way?

I’m finding Threading.Thread.Sleep(5000) isn’t perfect as the DB transaction doesn’t always complete in that time.

Any suggestions would be helpful. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:50:49+00:00Added an answer on May 13, 2026 at 9:50 am

    Try wrapping your InsertOnSubmit and SubmitChanges into a transaction, and commit before the redirect. I have a lot of very similar code and don’t see this issue. SubmitChanges() by default runs synchronously and will not return until the SQL has executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this code snippet that can be readily pasted into Linqpad (or slightly modified
I have this page in which I slightly modified the jQuery autocomplete to make
We have a custom site written in Perl that uses a slightly modified version
I have a slightly modified version of the thread class copied off the Linux
I have a couple slightly modified / non-traditional setups for feedforward neural networks which
I have a slightly theoretical question that I want to clear up before I
I have a need for two slightly different classes, that have the same members,
I have the following code slightly modified from the Visual Studio 2010 css template.
I have a jQuery plugin that uses a needle gauge. Upon initially loading a
I Have a UserControl called TenantList.ascx which contains a slightly modified GridView from DevExpress

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.