[英]MVC 3 Razor - Use script references in Layout page from Partial View
[英]MVC 3 - View rendered on top of the layout page
我在使用mvc 3在布局頁面中呈現視圖時遇到問題。
當我使用html helper渲染結果時,我的輸出位於頁面上所有內容的頂部,但是我使用了以下內容
HtmlHelper.ViewContext.HttpContext.Response
我將html輔助程序擴展到RenderModule方法,該方法提供了模塊名稱,並在我想像這樣使用它時執行其ActionResult :
@Html.RenderModule("modulename")
它給了我編譯錯誤
無法從void轉換為html字符串
因此,我應該這樣使用它:
@{ Html.RenderModule("modulename")}
但是,這導致在頁面頂部寫入輸出。
我該怎么辦?
提前致謝,
我已經使用了“ htmlhelper.viewcontext.httpcontext.respone”
那是你的問題。 您應該使用:
htmlHelper.ViewContext.Writer
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.