I have an application with a Firebase database and I need to show data in a list as a web page using ASP.NET MVC. I searched about it and I didn’t find any answer. I have data in Firebase realtime – data from my application, and I just want to show it in a list.
I tried this code, but the variable ends up being null.
public class DBController : Controller
{
IFirebaseConfig config = new FireSharp.Config.FirebaseConfig
{
AuthSecret = "**************************",
BasePath = "**************************"
};
IFirebaseClient client;
[HttpGet]
public ActionResult Index()
{
client = new FireSharp.FirebaseClient(config);
FirebaseResponse respones = client.Get("User");
dynamic data = JsonConvert.DeserializeObject<dynamic>(respones.Body);
var list = new List<DataModel>();
foreach(var item in data)
{
list.Add(JsonConvert.DeserializeObject<DataModel>(((JProperty)item).Value.ToString()));
}
return View(list);
}
}
And the view is just a list
New contributor
Ahmad Fuad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.