ASP.NET :: MVC :: Layout file

Master pages in MVC are a little different from that of ASP.NET. 

PlaceHolder is the one that holds a page's content inside the master page. In the same way, RequestBody() is the place where the view's data/content is placed and then rendered to the user.

RequestBody() is in the _Layout.cshtml page.

But how is it that MVC knows that it has to start _Layout.cshtml first before anything else is loaded??
That is in a file called _ViewStart.cshtml

This is the code inside it:

    Layout = "~/Views/Shared/_Layout.cshtml";


If we want to override a specific page that we can have a page with the same name in the folder of your views.

Say you have a folder Home and it has Index.cshtml and it should use a Layout called Layout2.cshtml file then create _Layout2.cshtml in the same folder.

You can even do this within the view as well like this:

    ViewBag.Title = "Home Page";
    Layout = "~/Views/Shared/_Layout2.cshtml";


git Config --global :: set your accounts default identity

I was working on to puch my node application to heroku last week. Before we can push the code to Heroku, we need to have Git (not GitHub) installed on our machines with a valid SSH token. Git, to reiterate, is a version control tool.
So, when i said >git commit, this was the msg that was shown.
Q) What did i do?
A) inplace of the user.email and user.name, give a value that you think you can remember day in and day out!!!

$ git commit

*** Please tell me who you are.


git config --global user.email "you@example.com"

git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'Obby@ObbyWorkstation.(none)')

MongoDB issues : Recover Data after an Unexpected Shutdown

Today while working on MongoDb, i had a power interruption and the system has restarted. when i tried to start mongod.exe with the command

>mongod.exe --dbpath E:\MyFolder\bin

it threw me an error stating there was an issue with the close connections of Mongod. This means that data sync has some issues and so mongod cannot start smoothly
The solution for this is:

check if there is a file named mongod.lock in the bin folder. If yes, check if its size is greater than 0kB.
If yes, then delete this file, because this is the one that is intimating mongod that there was an abrupt closure of the database the previous time.
now go back to the command line and say

>mongod.exe --journal (in case journal is not set for your db)
>mongod.exe --repair

this should set the database back in line and up and running.
if you get another error like
initandlisten] exception in initAndListen: 10296 dbpath (/data/db) does not exist, terminating

then exit the cmd line and rerun the repair command and then say

>mongod.exe --dbpath E:\MyFolder\bin

to set everything back in line.

Post json is empty in nodejs when used with postman

Using postman app for chrome, i was trying to post to my node js application listening to port 3001.
however, all the body of the data is sent as empty.
Because of this, the only data that is getting saved in mongodb using the mongoose connection was as below:

    "_id": "542e4ea1480f9abc13239976",
    "__v": 0

The issue with the code was that the body parser was placed at the end after the mongo connection was created and just above the app.listen(3001) line

When i changed the code to the top of the file just after the line

var app = express();
it worked for me.

now my complete code looks like this

var express = require('express');
mongoose = require('mongoose');
fs = require('fs');

var app = express();

app.configure(function () {
    app.use(express.logger('dev'));     /* 'default', 'short', 'tiny', 'dev' */

var mongoUri =  'mongodb://localhost/MyTestDatabase';

var db = mongoose.connection;

throw new Error('unable to connect to db');


//moved from here to the yellow highlighted section

console.log('Listening on port 3002...');

Android Studio :: upgrading to 0.8 and above from previous versions?

if you are upgrading from a previous version of Android Studio to 0.8 and above then with in your project, make sure
you change the following things:

In build.gradle, check if apply plugin reads as follows:
apply plugin: 'com.android.application'

at the bottom of the file, the dependencies should read like this

compile 'com.android.support:appcompat-v7:20.0.0'