简体   繁体   English

如何使用默认的_SiteLayout.cshtml文件呈现.ASPX页面?

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

I have a .aspx file. 我有一个.aspx文件。 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. 我需要在_SiteLayout.cshtml文件中调用它。

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.] [HttpException(0x80004005):文件“ /Shared/page.aspx”无法呈现,因为它不存在或不是有效的页面。]

The path is correct, /Shared/page.aspx is where the file is stored. 路径正确,/ Shared / page.aspx是文件存储的位置。

What can I do in this case? 在这种情况下我该怎么办?

Have you considered the @html.RenderAction() method, and have another acion rendering the page.aspx? 您是否考虑过@ html.RenderAction()方法,并使用另一个acion渲染page.aspx? I haven't tried but would assume it would work. 我没有尝试过,但会认为它会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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