怎么把 .aspx 生成 .html

tangyy 2004-04-16 08:27:59
怎么把 .aspx 生成 .html
...全文
84 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
myxcn 2004-04-18
  • 打赏
  • 举报
回复
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="CreateFile.aspx.vb" Inherits="test.CreateFile"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>CreateFile</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 64px; POSITION: absolute; TOP: 56px" runat="server"
Width="584px"></asp:TextBox>
<asp:TextBox id="TextBox2" style="Z-INDEX: 102; LEFT: 64px; POSITION: absolute; TOP: 104px" runat="server"
Width="608px" TextMode="MultiLine" Height="408px"></asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 296px; POSITION: absolute; TOP: 528px" runat="server"
Width="160px" Text="Button"></asp:Button></FONT>
</form>
</body>
</HTML>

----------------------------------------
Imports System.io
Public Class CreateFile
Inherits System.Web.UI.Page

#Region " Web 窗体设计器生成的代码 "

'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button

'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strTitle, strContent, strFolder As String
Dim i As Integer
Dim Arrjj As Array
strTitle = TextBox1.Text
strContent = TextBox2.Text
Arrjj = Split(strContent, "[page]")
Dim strFileName As String = Now.ToShortDateString.ToString & "_" & Now.Hour.ToString & "_" & Now.Minute.ToString & "_" & Now.Second.ToString & "_" & System.Guid.NewGuid.ToString.Substring(1, 3)
For i = 0 To UBound(Arrjj)
Dim strPath As String = Server.MapPath("News\" & Now.ToShortDateString.ToString & "\")
' 判断上传目录是否存在,不存在就建立
If (Not Directory.Exists(strPath)) Then
Directory.CreateDirectory(strPath)
End If
Try
Dim sw As StreamWriter = New StreamWriter(strPath & strFileName & "_" & i & ".shtml", False, System.Text.Encoding.Default) 'GetEncoding("gb2312")
' Add some text to the file.
sw.Write("<html>" & Chr(13))
sw.Write("<head>" & Chr(13))
sw.Write("<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & Chr(13))
sw.Write("<title>这是测试用的</title>" & Chr(13))
sw.Write("<style type=""text/css"">" & Chr(13))
sw.Write("<!--" & Chr(13))
sw.Write("body {" & Chr(13))
sw.Write(" font-size: 12px;" & Chr(13))
sw.Write("}" & Chr(13))
sw.Write("-->" & Chr(13))
sw.Write("</style>" & Chr(13))
sw.Write("</head>" & Chr(13))
sw.Write("<body>" & Chr(13))
'sw.Write("<!--#include file=""t.htm""--> " & Chr(13))
Dim str As String = Arrjj(i)
str = str.Replace(Chr(13), "<br>")
str = str.Replace(Chr(32), " " & Chr(32))
sw.Write("<center>" & strTitle & "</center><hr width=98% size=1>")
sw.Write(str & Chr(13))
'sw.WriteLine("header for the file.")
'sw.WriteLine("-------------------")
' Arbitrary objects can also be written to the file.
If UBound(Arrjj) - 1 > 1 Then
If i = 0 Then
sw.Write("<br><a href=" & strFileName & "_" & i + 1 & ".shtml>下一页</a>   当前第<font color=red>" & i + 1 & "</font>页/共<font color=red>" & UBound(Arrjj) + 1 & "</font>页")
ElseIf i > 0 And i < UBound(Arrjj) Then
sw.Write("<br><a href=" & strFileName & "_" & i - 1 & ".shtml>上一页</a>   <a href=" & strFileName & "_" & i + 1 & ".shtml>下一页</a>  当前第<font color=red>" & i + 1 & "</font>页/共<font color=red>" & UBound(Arrjj) + 1 & "</font>页")
Else
sw.Write("<br><a href=" & strFileName & "_" & i - 1 & ".shtml>上一页</a>   当前第<font color=red>" & i + 1 & "</font>页/共<font color=red>" & UBound(Arrjj) + 1 & "</font>页")
End If
End If
sw.Write("<br>The date is: ")
sw.WriteLine(DateTime.Now)
sw.Write("</body>" & Chr(13))
sw.Write("</html>" & Chr(13))
sw.Close()

Response.Write("OK")
Catch ex As Exception
Response.Write(ex.Message)
End Try
Next
Response.Redirect("/News/" & Now.ToShortDateString.ToString & "/" & strFileName & "_0.shtml")

End Sub

End Class
tangyy 2004-04-17
  • 打赏
  • 举报
回复
还有对.html的保存等
tangyy 2004-04-17
  • 打赏
  • 举报
回复
shitingzhao(淡淡一笑) 的是哦

我怎么没想到 :(:(:(

shitingzhao(淡淡一笑)你有一套方案吗,包括:对生成的.html的搜索等,可给你多加分,谢谢
潜水员2099 2004-04-17
  • 打赏
  • 举报
回复
你可以动态生成XML文件呀,然后配合CSS或者XSLT显示出HTML来
ppq886 2004-04-17
  • 打赏
  • 举报
回复
php中的知道一点 这个我也想知道,帮你顶

还有,能不能做成象php中可以做成任何后缀的伪装文件的方法?
tangyy 2004-04-17
  • 打赏
  • 举报
回复
对不起,我是说把动态页面.aspx 生成静态页面 .html , 象很多新闻发布系统.谢谢!!!
xiaozikuge 2004-04-17
  • 打赏
  • 举报
回复
同意楼上的哦
潜水员2099 2004-04-17
  • 打赏
  • 举报
回复
使用框架:
如:index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<TITLE>示例</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</head>
<frameset cols="242,68%">
<frame name="contents" src="Menu.aspx">
<frame name="main" src="">
<noframes>
<pre id="p2">
================================================================
关于完成此内容框架集的说明
1. 为“contents”框架添加 src="" 页的 URL。
2. 为“main”框架添加 src="" 页的 URL。
3. 将 BASE target="main" 元素添加到“contents”页的
HEAD,以将“main”设置为默认框架,“contents”页的链接将
在该框架中显示其他页。
================================================================
</pre>
<p id="p1">
此 HTML 框架集显示多个 Web 页。若要查看此框架集,请使用支持 HTML 4.0 及更高版本的 Web 浏览器。
</p>
</noframes>
</frameset>
</html>
tangyy 2004-04-16
  • 打赏
  • 举报
回复
slag(不知道)

说的那种,是的


========================

怎么搞的
slag 2004-04-16
  • 打赏
  • 举报
回复
你的意思是不是在浏览器里看见的后缀是.html
但是其实是ASPX的??
CExplorer 2004-04-16
  • 打赏
  • 举报
回复
在你的机器上装上IIS,越新越好。

还要装上FrameWork点几的。去网上找就行了。

然后在IE的地址栏里输入aspx文件的位置,按回车,页面就显示出来了。
tiannet 2004-04-16
  • 打赏
  • 举报
回复
在浏览器中打开这个aspx页面,
然后查看源文件,
就是html啦。
Overriding 2004-04-16
  • 打赏
  • 举报
回复
不明白楼主的意思,如果就是修改页面,那就不能用服务器端的控件了,只能用html标记。
<form>也不能用runat=server之类的了

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧