The Amazon DynamoDB Session State Provider allows ASP.NET applications store its sessions inside DynamoDB. This helps applications scale across multiple application servers while maintaining session state across the system.
This project builds an ASP.NET Session State provider that stores session in a DynamoDB table. The session state provider can retrieve from NuGet Packages.
Amazon DynamoDB is a fully managed cloud NoSQL database service – you simply create a database table, set throughput, and let the service handle the rest, and It supports both document and key-value store models. Amazon DynamoDB integrates with AWS Lambda to provide Triggers which enables you to architect applications that automatically react to data changes.
Amazon DynamoDB uses automatic partitioning and SSD technologies to meet your throughput requirements and deliver low latencies at any scale as your data volumes grow and application performance demands increase.
Task lists for module 3:
- To create session table in DynamoDB
- To Install, Manage and retrieve session state from NuGut Packages
- To check the session table updating data in the websites
The architecture of the project:
Steps for the tasks: To create session table in DynamoDB
In this task, I am going to create a pre-create session table in the AWS DynamoDb.
- Go to the DynamoDB Database from Services menu in the AWS management console. Click “Create Table” with Hash key attribute name: “SessionId“
- To access your AWS account programmatically, now You need to create Access key and secret key from your Amazon Account. Go to the AWS IAM for creating the Access key under your Security Credentials page. You will get this “Manage Security Credential” from IAM dashboard under “Delete your root access keys”. Note: Remember that, you have to download your key during creating access key; Otherwise, you will not able to retrieve your secret access key again.
Steps for the task: To Install, Manage and retrieve session state from NuGut Packages
- To manage your session state provider, You need to manage your NuGet Packages in your application. Go to your NET702.DinoStore – Manage NuGet Packages via Microsoft visual Studio.
- Now You require to the necessary installing references for the NET702.DinoStore project functioning correctly.
- In the Microsoft solution explorer, I selected NuGet targets under NuGet packages.
- Then I go to “Tools, and Click Package Manager Console from NuGet Package Manager. You can also manage package from “Manage Package for Solution” from NuGet Package Manager Tab. I prefer console mode. Note: For your understanding and comfortability I will show two procedures. You can choose anyone.
- Package Manager Console Mode:
- Run the code “Install-Package AWSSDK.DynamoDBv2 and Install-Package AWSSDK.Core, and Install-Package AWSSDK.S3” for Installing AWSSDK – Amazon DynamoDB 184.108.40.206 and AWS SDK for.NET, and AWSSDK – Amazon Simple Storage Service 220.127.116.11 ” on the “Package Manager Console” of NuGet with “.NET Framework, Version=v4.5″.
- “Install-Package AWS.SessionProvider” on the “Package Manager Console” to create AWS session provider.
- Manage Package for Solution Mode: You can also install the “AWSSDK from Manage Packagers for Solution” that I already installed by console mode.
- Until I’ve been writing, running, and editing my source code from the local server machine, now I will move source code to the cloud. So that I can work on my written code from the cloud platform. I will edit the code in web.config file so that I can create a new session in the cloud using AWS DynamoDB services.
To create the new session, you need to remove previous session details from web.config file ”
10. Then go to ShoppingCart.cs in NET702.DinoStore.Objects project via Microsoft Visual Studio. I will add a namespace “Serializable” in ShoppingCart.cs.
Serializationis the process of converting the state of an object into a form that can be persisted or transported. It used to save session state in ASP.NET and to copy objects to the clipboard in Windows Forms. It is also used by remoting to pass objects by value from one application domain to another.
Steps for the task: To check the session table updating data in the websites
In this task, I will check the session table on the DynamboDb table and update data on the website. The current situation is that there is no session created under the item in DynamoDB.
- Now you need to go back in the AWS DynamoDD to explore the session state table, the current state shows that there are no items.
- Now you view your application through the browser in order to check it is working properly or now.
- Now I will add an item to cart through login in the website by user ID that I have been created previously.When I will add the Dinosaurs into the cart, a session will be created in the DynamoDB table.
After adding an item to the cart, I explored my DynamoDB item table. I saw a new session has been created on the ASP.NET session state table in AWS.
The Problems can occur and solutions:
I’ve not got any problems during implementing module-3 but you can come out some issues.
Problem1. If you get difficult to install in AWSSDK
Solution: If you don’t get “Manager NuGet Package for Solution” from the tool menu NuGet Package Manage. Go to the “Extention and Updates” and then “Online” and download the “AWSToolsAndSDKForNet_sdk-18.104.22.168_ps-22.214.171.124_tk-126.96.36.199′, And install it.
You will get “Manager NuGet Package for Solution” under the NuGet Package Manager from Tools.
Problem2: If you forget to download Access Key and You could not able retrieve your secret access key. What will you do?
Solution: Delete the previous Access key from your Security Credentials. Then Create New Access key and download it for the secret key. After that change the new access key and secret key in the source code of the web.config file via Microsoft visual studio.
The next Module I will discuss “Configuring the System to Use Simple Queue Service”
Thank you 🙂