Step 1: Execute below query at your database:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 |
/********************************************************************* InstallSqlState.SQL Installs the tables, and stored procedures necessary for supporting ASP.NET session state on SQL Azure. Copyright Microsoft, Inc. All Rights Reserved. *********************************************************************/ SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ASPStateTempSessions]') AND type in (N'U')) DROP TABLE [dbo].[ASPStateTempSessions] GO IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ASPStateTempApplications]') AND type in (N'U')) DROP TABLE [dbo].[ASPStateTempApplications] GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'GetMajorVersion') AND (type = 'P'))) DROP PROCEDURE [dbo].GetMajorVersion GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'CreateTempTables') AND (type = 'P'))) DROP PROCEDURE [dbo].CreateTempTables GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempGetVersion') AND (type = 'P'))) DROP PROCEDURE [dbo].TempGetVersion GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'GetHashCode') AND (type = 'P'))) DROP PROCEDURE [dbo].GetHashCode GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempGetAppID') AND (type = 'P'))) DROP PROCEDURE [dbo].TempGetAppID GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempGetStateItem') AND (type = 'P'))) DROP PROCEDURE [dbo].TempGetStateItem GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempGetStateItem2') AND (type = 'P'))) DROP PROCEDURE [dbo].TempGetStateItem2 GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempGetStateItem3') AND (type = 'P'))) DROP PROCEDURE [dbo].TempGetStateItem3 GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempGetStateItemExclusive') AND (type = 'P'))) DROP PROCEDURE [dbo].TempGetStateItemExclusive GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempGetStateItemExclusive2') AND (type = 'P'))) DROP PROCEDURE [dbo].TempGetStateItemExclusive2 GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempGetStateItemExclusive3') AND (type = 'P'))) DROP PROCEDURE [dbo].TempGetStateItemExclusive3 GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempReleaseStateItemExclusive') AND (type = 'P'))) DROP PROCEDURE [dbo].TempReleaseStateItemExclusive GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempInsertUninitializedItem') AND (type = 'P'))) DROP PROCEDURE [dbo].TempInsertUninitializedItem GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempInsertStateItemShort') AND (type = 'P'))) DROP PROCEDURE [dbo].TempInsertStateItemShort GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempInsertStateItemLong') AND (type = 'P'))) DROP PROCEDURE [dbo].TempInsertStateItemLong GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempUpdateStateItemShort') AND (type = 'P'))) DROP PROCEDURE [dbo].TempUpdateStateItemShort GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempUpdateStateItemShortNullLong') AND (type = 'P'))) DROP PROCEDURE [dbo].TempUpdateStateItemShortNullLong GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempUpdateStateItemLong') AND (type = 'P'))) DROP PROCEDURE [dbo].TempUpdateStateItemLong GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempUpdateStateItemLongNullShort') AND (type = 'P'))) DROP PROCEDURE [dbo].TempUpdateStateItemLongNullShort GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempRemoveStateItem') AND (type = 'P'))) DROP PROCEDURE [dbo].TempRemoveStateItem GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'TempResetTimeout') AND (type = 'P'))) DROP PROCEDURE [dbo].TempResetTimeout GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'DeleteExpiredSessions') AND (type = 'P'))) DROP PROCEDURE [dbo].DeleteExpiredSessions GO IF (EXISTS (SELECT name FROM sysobjects WHERE (name = N'ASPStateTempSessions') AND (type = 'P'))) DROP PROCEDURE [dbo].DeleteExpiredSessions GO /*****************************************************************************/ CREATE PROCEDURE dbo.GetMajorVersion @@ver int OUTPUT AS BEGIN DECLARE @version nchar(100) DECLARE @dot int DECLARE @hyphen int DECLARE @SqlToExec nchar(4000) SELECT @@ver = 7 SELECT @version = @@Version SELECT @hyphen = CHARINDEX(N' - ', @version) IF (NOT(@hyphen IS NULL) AND @hyphen > 0) BEGIN SELECT @hyphen = @hyphen + 3 SELECT @dot = CHARINDEX(N'.', @version, @hyphen) IF (NOT(@dot IS NULL) AND @dot > @hyphen) BEGIN SELECT @version = SUBSTRING(@version, @hyphen, @dot - @hyphen) SELECT @@ver = CONVERT(int, @version) END END END GO /*****************************************************************************/ CREATE PROCEDURE dbo.CreateTempTables AS CREATE TABLE dbo.ASPStateTempSessions ( SessionId nvarchar(88) NOT NULL PRIMARY KEY, Created datetime NOT NULL DEFAULT GETUTCDATE(), Expires datetime NOT NULL, LockDate datetime NOT NULL, LockDateLocal datetime NOT NULL, LockCookie int NOT NULL, Timeout int NOT NULL, Locked bit NOT NULL, SessionItemShort VARBINARY(7000) NULL, SessionItemLong image NULL, Flags int NOT NULL DEFAULT 0, ) CREATE NONCLUSTERED INDEX Index_Expires ON dbo.ASPStateTempSessions(Expires) CREATE TABLE dbo.ASPStateTempApplications ( AppId int NOT NULL PRIMARY KEY, AppName char(280) NOT NULL, ) CREATE NONCLUSTERED INDEX Index_AppName ON dbo.ASPStateTempApplications(AppName) RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempGetVersion @ver char(10) OUTPUT AS SELECT @ver = "2" RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.GetHashCode @input varchar(280), @hash int OUTPUT AS /* This sproc is based on this C# hash function: int GetHashCode(string s) { int hash = 5381; int len = s.Length; for (int i = 0; i < len; i++) { int c = Convert.ToInt32(s[i]); hash = ((hash << 5) + hash) ^ c; } return hash; } However, SQL 7 doesn't provide a 32-bit integer type that allows rollover of bits, we have to divide our 32bit integer into the upper and lower 16 bits to do our calculation. */ DECLARE @hi_16bit int DECLARE @lo_16bit int DECLARE @hi_t int DECLARE @lo_t int DECLARE @len int DECLARE @i int DECLARE @c int DECLARE @carry int SET @hi_16bit = 0 SET @lo_16bit = 5381 SET @len = DATALENGTH(@input) SET @i = 1 WHILE (@i <= @len) BEGIN SET @c = ASCII(SUBSTRING(@input, @i, 1)) /* Formula: hash = ((hash << 5) + hash) ^ c */ /* hash << 5 */ SET @hi_t = @hi_16bit * 32 /* high 16bits << 5 */ SET @hi_t = @hi_t & 0xFFFF /* zero out overflow */ SET @lo_t = @lo_16bit * 32 /* low 16bits << 5 */ SET @carry = @lo_16bit & 0x1F0000 /* move low 16bits carryover to hi 16bits */ SET @carry = @carry / 0x10000 /* >> 16 */ SET @hi_t = @hi_t + @carry SET @hi_t = @hi_t & 0xFFFF /* zero out overflow */ /* + hash */ SET @lo_16bit = @lo_16bit + @lo_t SET @hi_16bit = @hi_16bit + @hi_t + (@lo_16bit / 0x10000) /* delay clearing the overflow */ /* ^c */ SET @lo_16bit = @lo_16bit ^ @c /* Now clear the overflow bits */ SET @hi_16bit = @hi_16bit & 0xFFFF SET @lo_16bit = @lo_16bit & 0xFFFF SET @i = @i + 1 END /* Do a sign extension of the hi-16bit if needed */ IF (@hi_16bit & 0x8000 <> 0) SET @hi_16bit = 0xFFFF0000 | @hi_16bit /* Merge hi and lo 16bit back together */ SET @hi_16bit = @hi_16bit * 0x10000 /* << 16 */ SET @hash = @hi_16bit | @lo_16bit RETURN 0 GO /*****************************************************************************/ DECLARE @cmd nchar(4000) SET @cmd = N' CREATE PROCEDURE dbo.TempGetAppID @appName varchar(280), @appId int OUTPUT AS SET @appName = LOWER(@appName) SET @appId = NULL SELECT @appId = AppId FROM dbo.ASPStateTempApplications WHERE AppName = @appName IF @appId IS NULL BEGIN BEGIN TRAN SELECT @appId = AppId FROM dbo.ASPStateTempApplications WITH (TABLOCKX) WHERE AppName = @appName IF @appId IS NULL BEGIN EXEC GetHashCode @appName, @appId OUTPUT INSERT dbo.ASPStateTempApplications VALUES (@appId, @appName) IF @@ERROR = 2627 BEGIN DECLARE @dupApp varchar(280) SELECT @dupApp = RTRIM(AppName) FROM dbo.ASPStateTempApplications WHERE AppId = @appId RAISERROR(''SQL session state fatal error: hash-code collision between applications ''''%s'''' and ''''%s''''. Please rename the 1st application to resolve the problem.'', 18, 1, @appName, @dupApp) END END COMMIT END RETURN 0' EXEC(@cmd) GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempGetStateItem @id nvarchar(88), @itemShort varbinary(7000) OUTPUT, @locked bit OUTPUT, @lockDate datetime OUTPUT, @lockCookie int OUTPUT AS DECLARE @now AS datetime SET @now = GETUTCDATE() UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, Timeout, @now), @locked = Locked, @lockDate = LockDateLocal, @lockCookie = LockCookie, @itemShort = CASE @locked WHEN 0 THEN SessionItemShort ELSE NULL END WHERE SessionId = @id RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempGetStateItem2 @id nvarchar(88), @itemShort varbinary(7000) OUTPUT, @locked bit OUTPUT, @lockAge int OUTPUT, @lockCookie int OUTPUT AS DECLARE @now AS datetime SET @now = GETUTCDATE() UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, Timeout, @now), @locked = Locked, @lockAge = DATEDIFF(second, LockDate, @now), @lockCookie = LockCookie, @itemShort = CASE @locked WHEN 0 THEN SessionItemShort ELSE NULL END WHERE SessionId = @id RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempGetStateItem3 @id nvarchar(88), @itemShort varbinary(7000) OUTPUT, @locked bit OUTPUT, @lockAge int OUTPUT, @lockCookie int OUTPUT, @actionFlags int OUTPUT AS DECLARE @textptr AS varbinary(16) DECLARE @length AS int DECLARE @now AS datetime SET @now = GETUTCDATE() UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, Timeout, @now), @locked = Locked, @lockAge = DATEDIFF(second, LockDate, @now), @lockCookie = LockCookie, @itemShort = CASE @locked WHEN 0 THEN SessionItemShort ELSE NULL END, /* If the Uninitialized flag (0x1) if it is set, remove it and return InitializeItem (0x1) in actionFlags */ Flags = CASE WHEN (Flags & 1) <> 0 THEN (Flags & ~1) ELSE Flags END, @actionFlags = CASE WHEN (Flags & 1) <> 0 THEN 1 ELSE 0 END WHERE SessionId = @id RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempGetStateItemExclusive @id nvarchar(88), @itemShort varbinary(7000) OUTPUT, @locked bit OUTPUT, @lockDate datetime OUTPUT, @lockCookie int OUTPUT AS DECLARE @now AS datetime DECLARE @nowLocal AS datetime SET @now = GETUTCDATE() SET @nowLocal = GETDATE() UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, Timeout, @now), LockDate = CASE Locked WHEN 0 THEN @now ELSE LockDate END, @lockDate = LockDateLocal = CASE Locked WHEN 0 THEN @nowLocal ELSE LockDateLocal END, @lockCookie = LockCookie = CASE Locked WHEN 0 THEN LockCookie + 1 ELSE LockCookie END, @itemShort = CASE Locked WHEN 0 THEN SessionItemShort ELSE NULL END, @locked = Locked, Locked = 1 WHERE SessionId = @id RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempGetStateItemExclusive2 @id nvarchar(88), @itemShort varbinary(7000) OUTPUT, @locked bit OUTPUT, @lockAge int OUTPUT, @lockCookie int OUTPUT AS DECLARE @now AS datetime DECLARE @nowLocal AS datetime SET @now = GETUTCDATE() SET @nowLocal = GETDATE() UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, Timeout, @now), LockDate = CASE Locked WHEN 0 THEN @now ELSE LockDate END, LockDateLocal = CASE Locked WHEN 0 THEN @nowLocal ELSE LockDateLocal END, @lockAge = CASE Locked WHEN 0 THEN 0 ELSE DATEDIFF(second, LockDate, @now) END, @lockCookie = LockCookie = CASE Locked WHEN 0 THEN LockCookie + 1 ELSE LockCookie END, @itemShort = CASE Locked WHEN 0 THEN SessionItemShort ELSE NULL END, @locked = Locked, Locked = 1 WHERE SessionId = @id RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempGetStateItemExclusive3 @id nvarchar(88), @itemShort varbinary(7000) OUTPUT, @locked bit OUTPUT, @lockAge int OUTPUT, @lockCookie int OUTPUT, @actionFlags int OUTPUT AS DECLARE @now AS datetime DECLARE @nowLocal AS datetime SET @now = GETUTCDATE() SET @nowLocal = GETDATE() UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, Timeout, @now), LockDate = CASE Locked WHEN 0 THEN @now ELSE LockDate END, LockDateLocal = CASE Locked WHEN 0 THEN @nowLocal ELSE LockDateLocal END, @lockAge = CASE Locked WHEN 0 THEN 0 ELSE DATEDIFF(second, LockDate, @now) END, @lockCookie = LockCookie = CASE Locked WHEN 0 THEN LockCookie + 1 ELSE LockCookie END, @itemShort = CASE Locked WHEN 0 THEN SessionItemShort ELSE NULL END, @locked = Locked, Locked = 1, /* If the Uninitialized flag (0x1) if it is set, remove it and return InitializeItem (0x1) in actionFlags */ Flags = CASE WHEN (Flags & 1) <> 0 THEN (Flags & ~1) ELSE Flags END, @actionFlags = CASE WHEN (Flags & 1) <> 0 THEN 1 ELSE 0 END WHERE SessionId = @id RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempReleaseStateItemExclusive @id nvarchar(88), @lockCookie int AS UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, Timeout, GETUTCDATE()), Locked = 0 WHERE SessionId = @id AND LockCookie = @lockCookie RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempInsertUninitializedItem @id nvarchar(88), @itemShort varbinary(7000), @timeout int AS DECLARE @now AS datetime DECLARE @nowLocal AS datetime SET @now = GETUTCDATE() SET @nowLocal = GETDATE() INSERT dbo.ASPStateTempSessions (SessionId, SessionItemShort, Timeout, Expires, Locked, LockDate, LockDateLocal, LockCookie, Flags) VALUES (@id, @itemShort, @timeout, DATEADD(n, @timeout, @now), 0, @now, @nowLocal, 1, 1) RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempInsertStateItemShort @id nvarchar(88), @itemShort varbinary(7000), @timeout int AS DECLARE @now AS datetime DECLARE @nowLocal AS datetime SET @now = GETUTCDATE() SET @nowLocal = GETDATE() INSERT dbo.ASPStateTempSessions (SessionId, SessionItemShort, Timeout, Expires, Locked, LockDate, LockDateLocal, LockCookie) VALUES (@id, @itemShort, @timeout, DATEADD(n, @timeout, @now), 0, @now, @nowLocal, 1) RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempInsertStateItemLong @id nvarchar(88), @itemLong image, @timeout int AS DECLARE @now AS datetime DECLARE @nowLocal AS datetime SET @now = GETUTCDATE() SET @nowLocal = GETDATE() INSERT dbo.ASPStateTempSessions (SessionId, SessionItemLong, Timeout, Expires, Locked, LockDate, LockDateLocal, LockCookie) VALUES (@id, @itemLong, @timeout, DATEADD(n, @timeout, @now), 0, @now, @nowLocal, 1) RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempUpdateStateItemShort @id nvarchar(88), @itemShort varbinary(7000), @timeout int, @lockCookie int AS UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, @timeout, GETUTCDATE()), SessionItemShort = @itemShort, Timeout = @timeout, Locked = 0 WHERE SessionId = @id AND LockCookie = @lockCookie RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempUpdateStateItemShortNullLong @id nvarchar(88), @itemShort varbinary(7000), @timeout int, @lockCookie int AS UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, @timeout, GETUTCDATE()), SessionItemShort = @itemShort, SessionItemLong = NULL, Timeout = @timeout, Locked = 0 WHERE SessionId = @id AND LockCookie = @lockCookie RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempUpdateStateItemLong @id nvarchar(88), @itemLong image, @timeout int, @lockCookie int AS UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, @timeout, GETUTCDATE()), SessionItemLong = @itemLong, Timeout = @timeout, Locked = 0 WHERE SessionId = @id AND LockCookie = @lockCookie RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempUpdateStateItemLongNullShort @id nvarchar(88), @itemLong image, @timeout int, @lockCookie int AS UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, @timeout, GETUTCDATE()), SessionItemLong = @itemLong, SessionItemShort = NULL, Timeout = @timeout, Locked = 0 WHERE SessionId = @id AND LockCookie = @lockCookie RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempRemoveStateItem @id nvarchar(88), @lockCookie int AS DELETE dbo.ASPStateTempSessions WHERE SessionId = @id AND LockCookie = @lockCookie RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.TempResetTimeout @id nvarchar(88) AS UPDATE dbo.ASPStateTempSessions SET Expires = DATEADD(n, Timeout, GETUTCDATE()) WHERE SessionId = @id RETURN 0 GO /*****************************************************************************/ CREATE PROCEDURE dbo.DeleteExpiredSessions AS DECLARE @now datetime SET @now = GETUTCDATE() DELETE dbo.ASPStateTempSessions WHERE Expires < @now RETURN 0 GO /*****************************************************************************/ EXECUTE dbo.CreateTempTables GO /*************************************************************/ /*************************************************************/ /*************************************************************/ /*************************************************************/ PRINT '' PRINT '------------------------------------------' PRINT 'Completed execution of InstallSqlState.SQL' PRINT '------------------------------------------' |
Step 2: Add following line your web.config file
1 |
<sessionState mode="SQLServer" sqlConnectionString="Connectionstring" cookieless="false" timeout="30" allowCustomSqlDatabase="true" /> |
Step 3: Make sure that session object is serialize.