Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1053763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:18:12+00:00 2026-05-16T17:18:12+00:00

We have old ASP.NET Forms pages and new MVC views and partial views in

  • 0

We have old ASP.NET Forms pages and new MVC views and partial views in the same solution. Some pages on the site are MVC and legacy pages are Forms. One of these legacy Forms pages is an .ascx control.

Is there any way for me to insert an MVC partial view (.ascx) into this Forms .ascx control?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:18:12+00:00Added an answer on May 16, 2026 at 5:18 pm

    I use this technique to embed MVC partials into webforms pages. Not sure if it works in a webforms user control, but it should be possible.

    Step 1. Within the MVC part of your application, create the following helper function. This does all the hard work:

    namespace MvcApplication
    {
        // create a dummy controller
        public class DummyController : Controller
        {
        }
    
        public static class MvcPartialHelper
        {
            public static void RenderPartial(string partialViewName, object model)
            {
                ControllerContext controllerContext;
                HttpContextBase httpContextBase;
                IView view;
                RouteData routeData;
                ViewContext viewContext;
    
                httpContextBase = new HttpContextWrapper(HttpContext.Current);
                routeData = new RouteData();
                routeData.Values.Add("controller", typeof(DummyController).Name);
                controllerContext = new ControllerContext(new RequestContext(httpContextBase, routeData), new DummyController());
                view = ViewEngines.Engines.FindPartialView(controllerContext, partialViewName).View;
                viewContext = new ViewContext(controllerContext, view, new ViewDataDictionary { Model = model }, new TempDataDictionary(), httpContextBase.Response.Output);
                view.Render(viewContext, httpContextBase.Response.Output);
            }
        }
    }
    

    then, within your web page (or user control):

    add the following to reference the above:

    <%@ Import Namespace="MvcApplication" %>
    

    and then when you need to display the partial you can add something like:

    <% MvcPartialHelper.RenderPartial("~/views/shared/TestPartial.ascx", "hello - this is my model"); %>
    

    where the second parameter is your ‘Model’.

    I use this technique extensively in a mixed MVC/Webforms environment and it works like a dream!

    Enjoy

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an old ASP.NET 1.1 site that I am maintaining. We are working
Currently converting an old asp.net web forms page into a asp.net mvc version, and
Retrofitting ASP.NET WebForms themes to an old application I have a need to theme
I have in here an old web application written in ASP.Net 2.0 + AJAX.
Age old question! When you have finished developing and testing your ASP.Net web application,
I have an old asp app I am moving to a new server with
I have a bunch of old classic ASP pages, many of which show database
I have installed an ASP.NET 4.0 Web forms application in IIS 7.5. If I
We have an ASP.NET application that uses Forms Auth. When users log in, a
I have an ASP.NET MVC 3 application with a SQL Server 2005 database backend.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.