Link to home
Start Free TrialLog in
Avatar of DistillingExperts
DistillingExperts

asked on

ASP .Net MVC: The resource cannot be found.

I have my Index.aspx set in the correct location but I am receiving the following error after I clicked in Set as Start Page:

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Views/Home/Index.aspx
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

If it is an MVC app then setting a start page won't work. The files with .ASPX extension aren't physical pages they are Views invoked by your controller. You don't navigate to pages, you invoke actions on controllers to get around.
try:
<sitedomain>/Home/Index
or even simply:
<sitedomain>

MVC uses routing to bind aspx pages (views) to virtual urls.
If you open global.asax, you'll see routes added to routes dictionary on application start. There should be a default rule and you can add as many rules as you want.
Each route added to the table has 3 parameters:
 - Route name: can be any string, e.g. "a route to a view that display items in categories"
 - Route pattern: formatted string describing route pattern.
E.g. "{controller}/{action}/{category}/{id}". Here controller and action are reserved for controllers and their public methods, the rest must match the method parameter names.
 - Object with pattern default values: this one must have a field for each piece of pattern in {} brackets. Considering the pattern above that would be for example:
new {controller = "Catalog", action="Show", category="Kitties", id=3 }

Now this route says that  the application should try to find controller named "{controller}", which has a public method named "{action}" and this method must take two arguments named "category" and "id". If application doesn't find any matching controller or method it goes to the next route and tries to parse the url accorfing to it.

You can define different patterns, even without names of controllers, methods, paramters, etc.
For example:
"Dat route",
"/WhosYourDaddy",
new {controller="Data", action="Remove", id="root"}
Now visiting link "<sitedomain>/WhosYourDaddy" will end up in calling
new DataController().Romove("root");
Avatar of DistillingExperts
DistillingExperts

ASKER

Sorry, but I didn't understand what I have to do to effectively fix my problem.
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial