English 中文(简体)
Render ASP.NET MVC string to View without HttpContext or ChiefContext?
原标题:Render ASP.NET MVC string to View without HttpContext or ControllerContext?

I need to render an ASP.NET MVC view to a string so as to be able to send it via an email (it is an order confirmation email defined in an .ascx file ).

我成功地使协会成为协会。 NET MVC 采用这种方法的观点。

然而,现在我需要能够通过一个世界合作框架服务(通过银灯获得)来做到这一点,因此,我没有一名主计长。 妇联的这一服务包含在与我的MVC项目相同的项目中,以便接触到我的所有模式等。

I ve looked at several questions on Stackoverflow about this issue, but they all seem to need a controller context. I thought there was something in mvccontrib but it doesn t seem to be there anymore.

我发现的最近一点是对上述问题的公认答案,但不幸的是,在你重新提出的观点中,它打破了当事方的分歧。

我可能想像一些幕后的人为伙伴关系工作。 NET MVC 2与“性别行动”有关,现在可能有助于实现这一目标?

问题回答

You need to create a fake HttpContextBase with a fake HttpRequestBase that return meaningful values from their properties.





相关问题
How to update shared view adminheader.cshtml from a model

I ve added a drop down into my shared adminheader.cshtl view and it needs to be dynamically updated from data from a table. So when I use another view like routeplan.cshtml I load the view from ...

ASP.NET MVC Razor view engine

After reading Scott Guthrie s blog entry about the new Razor view engine for ASP.NET MVC and reading this question comparing the available view engines. Razor seems to address most of the problems ...

Client Id for Property (ASP.Net MVC)

I m trying to do a label for a TextBox in my View and I d like to know, how can I take a Id that will be render in client to generate scripts... for example: <label for="<%=x.Name.ClientId%>"...

Get Current Area Name in View or Controller

How do you get the current area name in the view or controller? Is there anything like ViewContext.RouteData.Values["controller"] for areas?

MVC which submit button has been pressed

I have two buttons on my MVC form: <input name="submit" type="submit" id="submit" value="Save" /> <input name="process" type="submit" id="process" value="Process" /> From my Controller ...

热门标签