您的位置:首页 > 运维架构 > 网站架构

大型网站新闻系统如何生成静态网页

2006-12-30 16:10 435 查看
   大型网站的新闻系统 一般都是以静态html文件的形式出现,这样做的好处就是对搜索引擎友好,能保证搜索引擎有效地收录网站内容.

    下面我提出两种解决办法,首先看看微软的解决办法.

方法一:微软的解决办法:

Thisstep-by-steparticledescribeshowtoretrievetheHTMLresultsofapageasastreamandthendownloadthestreamtoafile.WhenyouusetheFileStreamobjectandsettheResponse.FilterpropertytotheFileStreamobject,allHTTPoutputthatResponse.Writesendsalsodownloadsasstreamtoafile.

CreateaWebForm

TocreateaWebForm:

1.

InVisualC#.NET,createanewASP.NETWebApplicationprojectnamedASPNETFilter.

2.

Right-clickthedesignerpaneofWebForm1.aspx.

3.

ClickViewHTMLSourcetoedittheHTMLcode.

4.

Replacetheexistingcodewiththefollowingcode:





































CreatetheResponseFilterClass

TocreatetheResponseFilterclass:

1.

AddanewclassnamedResponseFilter.cs.

2.

Replacetheexistingcodewiththefollowingcode:





















































































































































NoteBeforeyouruntheWebapplication:

1.

CreateafoldernamedC:/FilterOutput.

2.

GrantreadandwriteaccessonthefolderfortheASPNETuser.

 

UsetheResponseFilterClass

1.

InSolutionExplorer,selectWebForm1.aspx.

2.

Right-clickandthenselectViewCode.

3.

AddthefollowingcodetotheOnIniteventcode:





TesttheResponseFilter

1.

SavethechangestotheASPNETFilterWebproject.

2.

OntheBuildmenu,selectBuildSolution.

3.

StartMicrosoftInternetExplorer,andthenopenWebForm1.aspxbyspecifyingthefollowingURL,whereIISServerNameisthenameofyourMicrosoftInternetInformationServices(IIS)server:





4.

FindtheResponse.htmfileintheC:/FilterOutputfolder.

方法二:我的解决办法:













































































 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息