使用C#将aspx页面转换为html [英] Convert aspx page in to html using C#

查看:222
本文介绍了使用C#将aspx页面转换为html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人
我想将一个aspx页面转换为html.
我正在使用他的代码.但是它不起作用.


Dear all
I want to convert an aspx page into html.
I am using tHis code.But it is not working.


protected void btnpdf_Click(object sender, EventArgs e)
    {

        //Response.Redirect("Report.htm");
        WebRequest mywebReq;
        WebResponse mywebResp;
        StreamReader sr;
        string strHTML;
        StreamWriter sw;

        // Put user code to initialize the page here

        mywebReq = WebRequest.Create("http://localhost:4119/erp_layoutx1/dummyPrint.aspx?Pubdate=04/02/2011&pripub=DJ&pcenter=KNP&edition=KNP&suppcode=KNP&page_no=2&pubname=DAINIK%20JAGRAN&width=1280,height=738,resizable=1,left=0,top=0");
        mywebResp = mywebReq.GetResponse();
        sr = new StreamReader(mywebResp.GetResponseStream());
        //sr = new StreamReader(mywebResp.GetResponseStream(), System.Text.Encoding.ASCII);
        strHTML = sr.ReadToEnd();
        sw = File.CreateText(Server.MapPath("Report.htm"));
        sw.WriteLine(strHTML);
        sw.Close();
        Response.WriteFile(Server.MapPath("Report.htm"));
    }



请帮助.........



Please help.........

推荐答案

尝试使用HttpWebRequest代替.与使用WebRequest相比,您对它的工作方式拥有更多的控制权.
Try using HttpWebRequest instead. You have a lot more control over how it works than you do with WebRequest.


这篇关于使用C#将aspx页面转换为html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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