10

I have a very simple ASP.Net MVC Application that I have produced from an online tutorial. I've followed it exactly, step by step and have tried multiple times but keep getting the same error when I execute the code.

The program just displays an index page which lists a series of data from an sql server database using linq to sql.

This is the error:

Could not load type 'MvcApplication1.Views.Home.Index'.

Any ideas what the problem could be?

2
  • 1
    More info is required. Maybe post the stack trace Commented May 9, 2009 at 6:31
  • Do you have an index.aspx in your home folder? Commented May 9, 2009 at 17:16

5 Answers 5

13

Possible answer here:

http://www.jondavis.net/techblog/post/2009/04/29/Set-Up-IIS-For-An-MVC-App-When-All-Else-Fails-Check-View-Config.aspx

Basically, add the Views directory's web.config to your target Views directory. Although, it doesn't sound like you're using a strongly typed view, or aren't deploying your code.

Also, I have seen this problem also appear if the compile settings are removed from web.config. In an ASP.NET MVC project created in Visual Studio 2008, those settings are included in web.config, and they should remain or else this error will occur.

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

3 Comments

This looks like the solution to a similar problem I've been having, cheers (+1)
I had a similar problem caused by the absense of a PageParserFilterType attribute on the pages element of the web.config in the Views folder. Best thing is to create a blank project and check that file.
@Will - Had the same issue...created a new project and copied the web.config in the Views folder over to the existing project. @stimpy77 - +1 for leading us in the right direction
1

Are you running the current version of MVC? There was a big update in the Release Candidate that removed the code-behinds on views.

I ran into the same issue. Uninstalling MVC, then reinstalling fixed the problem for me. This can be done in Control Panel --> Add/Remove Programs.

Hope this helps, Adam

Comments

1

I had a similar "Could Not Load Type" problem with ASP.NET MVC in my Global.asax. The fix was to ensure the case of the inherits property was the same as the class it was referencing -- I didn't realize it was case sensitive!

Comments

0

The most possible reason is: you created another class / namespace or copied the web app to another solution

so there's no more class MvcApplication1 It has another name like FooApp2

Check the C# code behind the web page and replace MvcApplication1 with a proper name.

Comments

-1

That seems like a pretty ambiguous error to me. What hints does your Stack Trace give you? What framework method throws the exception?

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.