views:

79

answers:

1

I'm trying to find a way for the website owner to be able to easily edit static html pages and inject them into the master view.

I know I can do this with .ASCX files. I even have a route and controller that will inject an .ASCX whose name matches a parameter in the URL. But is there a way to do it with HTML files?

For reference, the code that works with .ASCX files looks like this:

 <% Html.RenderPartial((string)ViewData["PageName"]); %>

The URL looks like this:

http://www.mysite.com/staticpages/staticpagename.aspx

The controller method looks like this:

    public ActionResult RenderSpecifiedPage(string name)
    {
        ViewData["PageName"] = name;
        return View("Page");
    }

And the Route looks like this:

        routes.MapRoute(
            "Pages",                                                                        // Route name
            "staticpages/{name}.aspx",                                                             // URL with parameters
            new { controller = "Page", action = "RenderSpecifiedPage", name = "Page" }      // Parameter defaults
        );
A: 

Already been asked, you can find it here: http://stackoverflow.com/questions/1196379/asp-net-mvc-renderpartial-for-a-static-html-file

Dale Ragan