Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aspx pages will not load after upgrading from Asp.net MVC 2 to 3 RC

Tags:

I upgraded to Asp.net MVC 3 RC last night and I followed the instructions on the release notes. However, normal Aspx pages no longer work.

For example, when I go to the root (Home/Index), the following error occurs:

The view at '~/Views/Home/Index.aspx' must derive from ViewPage, ViewPage<TModel>, ViewUserControl, or ViewUserControl<TModel>. 

This is using a barely modified version of the original MVC Home/Index view. The code is:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>  <asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">     Home Page </asp:Content>  <asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">     <h2><%= Html.Encode(ViewData["Message"]) %></h2>     <p>         <%= Html.ActionLink("Project List", "List", "Project", new { area = "writing" }, null) %>     </p> </asp:Content> 

It is setup to inherit from ViewPage, so I'm not sure what the issue is.

The master page is unmodified from what MVC installs.

Any ideas?

like image 503
KallDrexx Avatar asked Nov 11 '10 22:11

KallDrexx


People also ask

Can you use ASPX pages in MVC?

If you add a plain ASPX page to an ASP.NET MVC project, well, it just works like a charm without any changes to the configuration. If you invoke the ASPX page, the ASPX page is processed with viewstate and postbacks.

How do I change the default page in ASP NET MVC?

You can set up a default route: routes. MapRoute( "Default", // Route name "", // URL with parameters new { controller = "Home", action = "Index"} // Parameter defaults ); Just change the Controller/Action names to your desired default.

What is ASP Net mvc6?

ASP.NET MVC is a web application framework developed by Microsoft that implements the model–view–controller (MVC) pattern. It is no longer in active development. It is open-source software, apart from the ASP.NET Web Forms component, which is proprietary. ASP.NET MVC.


1 Answers

make sure you web.config has

<assemblies>     <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />     <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />     <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />     <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />     <add assembly="WebMatrix.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />     <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />     <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />   </assemblies> 

and this

<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">   <dependentAssembly>     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />     <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />   </dependentAssembly> </assemblyBinding> 

as well as in any Areas/Web.config

Update them as needed and you should get to a better place

like image 197
Phil Strong Avatar answered Nov 11 '22 15:11

Phil Strong