Rendering a view to a string in ASP.NET MVC 2

心已入冬 提交于 2019-11-30 21:32:51
Frank Rosario

I figured it out. The issue with ExecuteResult wasn't working as expected was because I hadn't mocked the ControllerContext properly. I was able to solve the issue by mocking the controllercontext as described in this SO post:

Mocking Asp.net-mvc Controller Context

Hope this post helps someone in the future if they're trying to do something similar.

Colin Newell

I haven't tried it myself but Phil Haack did suggest a way to output a view to a string here with MVC in mind.

Darin Dimitrov

MVCContrib has a BlockRenderer class which could be helpful for this scenario.

Not a direct answer to your question, but why would you render the whole view as a string to your search index, rather than either a) pushing the data itself into the index (LINQ to Lucene lets you do this w/ attributes) or b) offloading the work to a separate process that crawls the front end using some set of rights?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!