Controllers in an MVC application

1)First of all if there is a MVC4 in visual studio then you create a new project.

2)Then go in to solution explorer in that click on  App_start

Then there is a Routeconfig.cs click right click on that

Then go to option To go to defination.

3)Then write a code in that Home Controller

{

public string Index(string Id)

{

return “Id=”+Id+”and Name=”+name;  or +Request.querystring[“name”];

}

public string GetDetails()

{

return “GetDetails Invoked”;

}

In URL,

localhost/MVCDemo/home/index/10?name=pragim

↓                              ↓                      ↓               ↓           ↓

servername     project      Controller   Actionmethods

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s