如何从当前请求得到HTML,以回传 [英] How to get HTML from a current request, in a postback

查看:91
本文介绍了如何从当前请求得到HTML,以回传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的HTML生成报告。

I have a report that I generate with HTML.

我想获得页面的HTML输出,并能够通过电子邮件发送。我遇到会话问题,因为该报告我重定向到登录页面,因为当我创建一个新的WebRequest,它不使用当前会话的信息。

I'd like to get the HTML output of the page, and be able to send it via email. I'm having problem with session, because the report redirect me to the login page because when I create a new WebRequest, it doesn't use the information of the current session.

有没有办法让该报告的HTML,而无需code一个变通的安全性?

Is there a way to get the HTML of the report without having to code a work-around for the security ?

感谢您

推荐答案

这code把工作做好

StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter htmlTW = new HtmlTextWriter(sw);

RenderControl(htmlTW);

string html = sb.ToString();

这篇关于如何从当前请求得到HTML,以回传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆