Click here to Skip to main content
15,891,847 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,

I'm new to MVC learning MVC form 4 days..At present i'm doing example based on Consume Business layer in MVC..i'm getting the following error

Server Error in '/' Application.

The resource cannot be found.

Help me to resolve this problem ..

Thank you
Posted
Comments
Arjsrya 7-Jan-15 4:12am    
You should call the correct controller and action method.

Controller:EmployeeController
Action:GetEmployees

example:http://codeproject.com/Employee/GetEmployees
Member 11148509 7-Jan-15 5:26am    
Unable to open the link u have sent ..

 
Share this answer
 
Comments
Member 11148509 7-Jan-15 5:28am    
Checked the site couldn't solve the problem..
Since you have started with MVC, you would be aware of Controller and Action.
So basically in MVC the request is mapped with the Route specified in your
App_Start->RouteConfig.cs, that means the route and request basically are in the below format:- (incase you are running on localhost)
localhost:port/Domain(Root Project Name)/Controller/Action
So, if any of the parameter in the url is not mentioned either you get IIS error, or Resource not found error.
Also if you are accessing a perfect url mentioned above, but the COntroller or the Action mentioned is not implemented or there in the project then Resource not found is thrown.
Lastly, if the default url/route is not set, then you get Resource not found. So to set default Route,
You need to make changes in the Route config.cs like below
C#
routes.MapRoute(
              name: "Default",
              url: "{controller}/{action}/{id}",
              defaults: new { controller = "NAME", action = "ACTION NAME", id = UrlParameter.Optional }
          );

Please post back your queries if any.
Thanks
 
Share this answer
 
Comments
Member 11148509 7-Jan-15 6:48am    
code in controller and in view i have created code automatically .....


public class EmployeeController : Controller
{


public ActionResult Index()
{
EmployeeBusinessLayer employeebusinesslayer = new EmployeeBusinessLayer();
List<employee> employees = employeebusinesslayer.Employees.ToList();
return View(employees);
}

}
}
[no name] 7-Jan-15 7:06am    
ok then the url u are using is??
[no name] 7-Jan-15 7:29am    
It is /Employee/Index
Right??
Member 11148509 7-Jan-15 7:34am    
yes ...
Member 11148509 7-Jan-15 7:32am    
http://localhost:5156/Employee/index

and Thank you got it....its the error in web.config and after that its just showing exception ...for establising connection ...i will try to resolve that....
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900