Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 4 - The view 'WebForm1.aspx' must derive from ViewPage, ViewPage<TModel>, ViewUserControl, or ViewUserControl<TModel> [duplicate]

I am working with rdlc report (ASP.Net MVC 4 with VS2012). Since view can't handle report viewer control I put the report viewer inside a user control file, .aspx file. Unfortunately when I render to view (WebForm1.aspx) it creates error: The view at 'WebForm1.aspx' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.

I have searched the solution around the web but till now could find no solution. Do you have any idea?

like image 592
Sami-L Avatar asked Mar 16 '13 12:03

Sami-L


1 Answers

I've inadvertently caused this to happen more than a few times in MVC applications, and it generally has to do with one of the following:

  • Having multiple versions of MVC referenced in the project. Similar to this question. I've had it bite me a few times when going from MVC 2 to MVC 3, though I can't say it's happened to me in MVC4.

  • MVC trying to use the wrong ViewEngine to render the View. Since you're using .aspx for the view, did you make sure to set up the project to use the WebForms view engine and not Razor? I'd imagine it'd probably toss that error if Razor was trying to parse WebForms.

  • Configuration files (specifically web.conf) not having the correct data for your project. Similar to this question.

like image 57
antinescience Avatar answered Sep 20 '22 16:09

antinescience