0

I am having problems trying to get a very simple ASP.Net application to start using .Net Framework 4 and MVC 2.

When press F5 in Visual Studio 2010, I get the following error message HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unable. Please review the following URL and make sure it is spelled correctly.

When I added the view, I added the view by right clicking on the method in the controller, and this of course added the view. I have also noticed that when selecting "Go to View", that this too throws an error in Visual Studio and says that the view does not exist! Further, I have gone to the Global.asax page and changed the default controller to be that of the one I have added, but this has made NO difference.

So, please tell me - but do I need to change?

2
  • Show us your default routes and Commented Sep 16, 2011 at 15:35
  • could you post the entire error message with tracing? I like to see your request Url, gobal.asax and controller. Commented Sep 16, 2011 at 15:42

3 Answers 3

2

Try to go to /ControllerName/ActionName. If you have changed the default, you have to make sure you have spelled it correctly. Also note that the ASP.NET MVC Framework removes the "Controller" suffix of controller names.

If your new controller is called MyNewController it should:

  1. Inherit from Controller
  2. Be called MyNewController

Like this

public MyNewController : Controller {
    public ActionsResult MyAction() {
       return View();
    }
}

In Global.asax.cs for this case, the default settings counld be:

routes.MapRoute(
    "Default", 
    "{controller}/{action}/{id}", 
    new { controller = "MyNew", action = "MyAction" }
);

Note how the default controller setting lacks the "Controller" suffix.

Sign up to request clarification or add additional context in comments.

Comments

0

To install MVC some considerations need to be take in account. I think you are trying to install it on IIS 5 or 6

Please read this article http://blog.stevensanderson.com/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/ or upgrade to IIS 7

2 Comments

I am running this locally on my machine which is running windows 7
What version of IIS do you have ?
0

Had a similar problem. I had made the mistake of modifying the default route from this:

url: "{controller}/{action}/{id}",

To this:

url: "{controller}/{action}/{id*}",

Placing the asterisk in the wrong place caused absolutely every URL to give me a 404 - and as usual ASP.Net routes are practically impossible to debug.

The solution was placing the asterisk in the proper place:

url: "{controller}/{action}/{*id}",

(This allows routes with as many forward slashes as you like, instead of limiting them to 3. The portion with an asterisk is a catchall.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.