-1

我写了这段代码

 public partial class monograph : System.Web.UI.Page
    {
        public string path = "file:///D:/CD IP/Html/Monographs/";
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            path = path + Label1.Text + ".htm";
            Response.Redirect(path);
        }
    }

如何从上面的代码打开html页面?

4

3 回答 3

2

为什么要使用“file:///D:/CD IP/Html/Monographs/”来打开 HTML 页面。如果您的 aspx 和 html 页面位于同一文件夹中,则您必须使用相对路径或只提供 HTML 文件名。

于 2012-05-25T06:54:28.817 回答
0

使用相对网址。在您的应用程序或网站中托管您的 html。

像这样的东西

Response.Redirect("~/Html/Monographs/"+fileName+".htm");

文件:对用户 pc 进行假设

于 2012-05-25T06:56:18.897 回答
0

如果您想在 asp.net 中显示您的 html 文件,请在项目文件夹中使用任何名称创建文件夹并放置您的 hmtl 文件。例如

假设我创建了 palinData 文件夹并在其中复制了 1.html。你可以给一个链接

lnk.HRef=Server.Mappath("~") + "/plainData/1.html"
于 2012-05-25T06:57:20.377 回答