Custom errors in MVC


Example Return for result in controller

Inside of View page,

what is Model in MVC ?

MVC is

  • Data (Model)
  • An interface to view and modify the data (View)
  • Operations that can be performed on the data (Controller)


M + V = C>>    Controller is  preparing Model then creating  View.

In the Center  there is a Controller


For Simple  >   Model = ‘ DATAS’    

* The model is the data, and does nothing else.

Models (All of models in project ) does NOT depend on the controller or the view.

Controller Calling Model then  pushing it  to  View.    Controller is handling. But for the preparing the datas,  controller does not effect  how the model creating data sets, structs, objects.

Controller says model to that: Prepare user_table[array] ,

After pushing this  object  to  View,  View is using this table,


what is Controller ?

Such as button clicks. The controller depends on the view and the model.


The controller and the view are the same object. WHY >    You can return   a string   as a page   return  “”


 What is the Advantage of model ?

Unnecessary complexity is the devil of software development.

Time loss for companies.  .  Complexity leads to software that is buggy, and expensive to maintain.

The easiest way to make code overly complex is to put dependencies everywhere.

* You can use model, Directly  Copy paste inside of another  Project.  You can Call the Model from  different  Views, or Controllers.
>>  Conversely, removing unnecessary dependencies makes delightful code that is less buggy and easier to maintain because it is reusable without modification.

* The primary advantage of the MVC is that makes model classes reusable without modification.


create new view


This view  should be in   “Shared Folder”

Otherwise it can give error ,  “The view or its master was not found or no view engine supports the searched locations”

1- Controller Name is important,

if you do not have the file inside of   “view folder ” ,
 it will look shared,   . Firstly  it is looking

 >>    “view folder/ControllerName/Filename”


Creating New MVC Project

new MVC project,

File > New  > Project > MVC 4 project.

1- Select  ASPX instead of  RAZOR Syntax,

2- Remove all of Other Content of  Directories

— How to add Controller and  return string,  Which URL

>> Add new Controller !!!    url   localhost/ControllerNAME/



– How MVC calling controller, ?

Global.asax Fil e     calling route table, after route table calling controllers


Route Config.cs  > Called by Global.asax