views:

30

answers:

2

Using asp.net MVC in c#, I am making a call to a stored procedure using Linq into my SQL Members table. I have no internal caching on the application, already checked to make sure it is turned off.

Test case: I have my username set to test1. From the website I change my username to test2. The website still shows test1. I go to Management Studio and run my stored procedure called MemberByEmail, it shows test2 correctly.

I start simple, refresh my page to see if it's browser cache, still test1. I go to debugging and walk through the code and find that it goes correctly all the way to here to call the database:

/// <summary>Method that is mapped to the dbo.MemberByEmail database procedure.</summary>
    /// <returns></returns>
    [System.Data.Linq.Mapping.Function(Name="dbo.MemberByEmail")]
    public System.Data.Linq.ISingleResult<BookCrossing.Data.Member> MemberByEmail(
        [System.Data.Linq.Mapping.Parameter(DbType="nvarchar(100)")] string email)
    {
        var methodInfo = (System.Reflection.MethodInfo)System.Reflection.MethodInfo.GetCurrentMethod();
        var result = this.ExecuteMethodCall(this, methodInfo, email);

        return ((System.Data.Linq.ISingleResult<BookCrossing.Data.Member>)(result.ReturnValue));
    }

I turned on the profiler for my sql db, and it actually shows an entry for MemberByEmail, and the result set that came back had username = test1 .

Again I ran the stored procedure through Management Studio, and it came up with test2 as the username. I waited for 15 minutes, refreshing the web page every 5 or so, and it never cleared and served the correct test2 from the db. The last strange piece, I ran IISReset and refreshed the page, test2 was returned.

I'm guessing this I am just overlooking something obvious. Any help or advice would be great. Thanks

UPDATE: I created a console application to take out the web piece of it. The problem is the same when accessing directly from a console app also, no change.

A: 

How are you calling this from the webpage? If via an Ajax call, IE helpfully caches the result for you...

Clicktricity
This one isn't called by Ajax, it's part of a full page reload.
Matt
A: 

Took a while but we got this resolved. Data access is done through a MemberRepository in our project, and we loaded member repository in our MembershipProvider class. The problem is that the MembershipProvider class was loaded at the start of the application and never removed, so all MemberRepository calls were done through the same context. The strange part is that the call went all the way to SQL (as noted we were able to see the request in profiler), but the bowels of the code got back the results set but instead used the first calls result set and sent that back to us.

So by moving the Repository into the desired method or our MembershipProvider, it was destroyed after each call and that solved the issue. I don't know that this is specific to our set up, but hopefully it will help someone in the future.

Matt