Code2night
  • Home
  • Guest Posts
  • Tutorial
  • Languages
    • Angular
    • C
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
    • Word Counter
    • Base64 Encode/Decode
    • Diff Checker
    • JSON to CSV
    • Password Generator
  • Register
  • Login
  1. Home
  2. Blogpost

Using Firebase Database in Asp.Net

Date- Sep 22,2022

10005

Free Download Pay & Download
Firebase Firebase Database

FireBase Database

Firebase is used with mobile and web applications in order to have better performance across mobile devices.For saving the data to Firebase database from Asp.net Web application we have to first create firebase database and we have to signup to firebase console for that purpose.After going to firebase console signup with Firebase console and follow these steps:

1. First of all click on create a project.

2. Now enter the data as showed in the below screenshot

3. Now click on continue

4. Select your location and click on create project

5. Now you project will be started to create. It can take few seconds. Click on continue

6. Now your project is created and click on the code icon as showed in the image

7. Now you have to add new app in your project.

8. Click on next

9. Click on next again

10. Click on continue to console

11. Now  click on the settings icon as showed below


12.Now click on realtime database and create database

13. Now select the dropdown and click on the button 

14. Click on the test mode and click on the button

15. Click on the button again and your database will be created

12. Now click on service accounts tab

13. Now click on the highlighted tab  and you can copy the secret key that you will use later in the code part . These are the database secret key that we have to use in our Asp.Net application

Asp.Net Project

Now we will create new asp.net mvc project and add FireSharp Nuget package

We will use this package for sending the data to firebase database

Now create one new action and copy the code below


using FireSharp.Config;
using FireSharp.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Firebase.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            string authSecret = "5VBhC2rR7q7bC8ag42Ejr3f2TcOerJxIpuPRUzxQ"; //Enter your database secret here
            string basePath = "https://code2night-8d351-default-rtdb.firebaseio.com/"; //Enter your database url
            string senderAppName = "Code2night"; 

            IFirebaseClient client;
            IFirebaseConfig config = new FirebaseConfig
            {
                AuthSecret = authSecret,
                BasePath = basePath

            };

            client = new FireSharp.FirebaseClient(config);
            if (client != null && !string.IsNullOrEmpty(basePath) && !string.IsNullOrEmpty(authSecret))
            {

                var data = new 
                {
                    Name="Test",
                    Mobile="234234"
                };

                var response = client.Push("doc/", data);
            }
            return View();
        }
        
    
    }
}

Now we have to run the application and you will see our data will be saved to firebase database. You can check the output in the screenshot below

So, this is how we will be using Firebase database in Asp.Net web application. 

S
Shubham Batra
Programming author at Code2Night โ€” sharing tutorials on ASP.NET, C#, and more.
View all posts โ†’

Related Articles

Integrate Stripe Payment Gateway In ASP.NET Core 8.0
Nov 23, 2023
Integrate Stripe Payment Gateway In ASP.NET Core 7.0
Jul 22, 2023
Implement Stripe Payment Gateway In ASP.NET Core
Jul 01, 2023
Get Mime Type for any extension in Asp.Net
May 15, 2023

Comments

Tags

AspNet
C#
programming
AspNet MVC
c programming
AspNet Core
C
software development
tutorial
MVC
memory management
Paypal
coding
coding best practices
data structures
programming tutorial
tutorials
object oriented programming
Slick Slider
StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1760
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blogs
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
Free Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Diff Checker
  • Base64 Encode/Decode
  • Word Counter
By Language
  • Angular
  • C
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ยท  Terms
Translate Page