8

I am using ASP.NET MVC 3 and have some parts written using aspx. So in some of my views I have something like this

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="Thread.Index" %> 

But I've already create Layout for site using Razor's Layout and I want to use that layout in this .aspx file too.
How can i achieve this?

2
  • So you want to use a Razor layout file as a master page for a view coded using the aspx view engine? Commented Sep 1, 2011 at 7:43
  • Yes, I don't want to have both layout and master page in my application. Commented Sep 1, 2011 at 7:47

3 Answers 3

13

I recently blogged about this at here,

http://weblogs.asp.net/imranbaloch/archive/2011/09/01/a-webform-view-with-a-razor-layout-in-asp-net-mvc-3.aspx

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

1 Comment

Thanks for the inspiration, which I used to solve my problem. This approach can be modified to host a WebForms Page inside an MVC Master Layout. Sorta kinda totally cool. (For those suckers who need to mix WebForms and MVC pages.)
6

You cannot use Razor layouts with WebForms views. You will need to create a WebForms masterpage for WebForms views. View engines cannot be mixed like this.

Comments

1

I'm pretty sure you can not mix the 2 different view engines (The Razor view engine and the old ASPX view engine).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.