我将 Razor 与网页一起使用,但没有使用 MVC。我喜欢这种简单性,所以目前我对使用 MVC 不感兴趣。不过,我希望能够将部分内容渲染到我的页面中。如菜单、页脚等。
使用 MVC,您可以: @{ Html.RenderPartial("页脚", 模型);}
我想做类似的事情: @{ Html.RenderPartial("footer.cshtml"); }
如何才能实现我想要的目标?
最佳答案
看看这个链接http://www.mikesdotnetting.com/Article/151/Extending-ASP.NET-Web-Pages-Create-Your-Own-Helpers
希望这对您有帮助
也试试这个:
<!DOCTYPE html>
<html>
<head>
<title>Main Page</title>
</head>
<body>
@RenderPage("/Shared/_Header.cshtml")
<h1>Index Page Content</h1>
<p>This is the content of the main page.</p>
@RenderPage("/Shared/_Footer.cshtml")
</body>
</html>
关于asp.net - 在不使用 MVC 的情况下渲染网页中的部分内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15654295/