简体   繁体   中英

How can I render a .ASPX page using my default _SiteLayout.cshtml file?

I have a .aspx file. It contains within it all the code I need to render a part of my webpage. I need to call it within my _SiteLayout.cshtml file.

I have tried the usual way, by calling :

@{  
    Layout = "/Shared/_SiteLayout.cshtml";
}
        @RenderPage("Shared/page.aspx");

However this results in the error -

[HttpException (0x80004005): The file "/Shared/page.aspx" could not be rendered, because it does not exist or is not a valid page.]

The path is correct, /Shared/page.aspx is where the file is stored.

What can I do in this case?

Have you considered the @html.RenderAction() method, and have another acion rendering the page.aspx? I haven't tried but would assume it would work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM