I make controller in asp mvc2 app. After that i create view for this controller.
I named this controller "DisplayName" And write something like :
public class DisplayName : Controller
{
//
// GET: /DisplayName/
public ActionResult Index()
{
return View();
}
public ActionResult DisplaySomething()
{
MojaKlasa objCustomer = new MojaKlasa();
objCustomer.ime = "Random ime";
objCustomer.broj = 10;
return View("DisplaySomething", objCustomer);
}
}
But when I try to display it in web browser and call:
http://localhost:xxxxx/DisplayName/DisplaySomething
I get error :
Server Error in '/' Application. The resource cannot be found.
I trying to find error and then i see one sample and rename controller in DisplayNameController
Now i have:
public class DisplayNameController : Controller
{
//
// GET: /DisplayName/
public ActionResult Index()
{
return View();
}
public ActionResult DisplaySomething()
{
MojaKlasa objCustomer = new MojaKlasa();
objCustomer.ime = "Random ime";
objCustomer.broj = 10;
return View("DisplaySomething", objCustomer);
}
}
And now when i call:
http://localhost:xxxxx/DisplayName/DisplaySomething
app work perfect.
My question is next: Is this mean that every controller need to have "Controller" in name? why i cannot just use name that I want?
Thanx