1

I'm trying to use the asp.net webforms sitemap and menu control to build my asp.net mvc's sites navigation.

There are many tutorials about embedding razor views into webforms, but I want to go the otherway around. Embed a webform into a razor view.

Doing something like this looks eemi promising:

@Html.Partial("~/Views/Shared/test/menu.aspx")

Which presents an error:

Parser Error Message: 'System.Web.Mvc.ViewUserControl' is not allowed here because it does not extend class 'System.Web.Mvc.ViewPage'.

Is there a value for Inherits that would allow this to work?

1 Answer 1

6

Oh Duh, read the error message...

I changed the first line of the webform from this:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="menu.aspx.cs" Inherits="System.Web.Mvc.ViewUserControl" %>

to this:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="menu.aspx.cs" Inherits="System.Web.Mvc.ViewPage" %>

Then I ran into another issue about System.Web.Mvc.ViewPage being defined twice, so I deleted the *.designer.cs file and now its working.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.