有很多网站的新闻系统是用的.aspx?id=34534我想做成动态的.aspx全部生成为123.aspx,456.aspx,....integer.aspx请问具体怎么写呢?希望能写一下具体的代码

解决方案 »

  1.   

    这个需要用UrlRewriter,具体请搜索.
      

  2.   

    生成静态页面吧!
    XX.aspx?id=1 -----> 1.htm
    XX.aspx?id=n -----> n.htm当访问XX.aspx?id=n 时,把n.htm给他
      

  3.   

    Dim sUrl As String = "http://localhost/ReturnData.aspx?id=dynamic"
            Dim result As String = ""
            Dim MyResponse As System.Net.WebResponse
            Dim MyRequest As System.Net.WebRequest
            MyRequest = System.Net.HttpWebRequest.Create(sUrl)
            MyResponse = MyRequest.GetResponse
            Dim MyReader As System.IO.StreamReader = New System.IO.StreamReader(MyResponse.GetResponseStream(), Encoding.Default)
            result = MyReader.ReadToEnd
            MyReader.Close()
            Dim fs As System.IO.FileStream = New System.IO.FileStream(Server.MapPath("\path\..."), IO.FileMode.Create, IO.FileAccess.Write)
            Dim wt As System.IO.StreamWriter = New System.IO.StreamWriter(fs, Encoding.Default)
            wt.WriteLine(result)
            wt.Close()
            fs.Close()我不知道怎么用?我想生成全部为 .aspx的,不要.htm的这样设置它的缓冲有效日期呢?如何更新文件呢,真希望谁能写个例子讲解一下
      

  4.   

    Source.aspx?request=123  -->  123.aspx
    Source.aspx?request=ms   -->  ms.aspx
    Source.aspx?request=system.net  --> system.net.aspx............
    how to make?,thanks very much,waiting your message.,
    我不知道为什么,我这几天上MSDN速度很慢,其他都快,不方便找资料,真心等待大家帮助
      

  5.   

    或者想MS的论坛那样,比如请求
     /path/123456/default.aspx
    /path/test/default.aspx
    /path/Microsoft.Net/default.aspx
    /path/ms123456/default.aspx
    ................这些都是一个原理吧,大哥们,请写个例子讲解一下方法和需要调用的对象吧。
      

  6.   

    首先,将XXX.aspx?id=xxx 转换为 xxx.asspx属于Url重写,这个东西不难,你按楼上的说的UrlRewriter
    去搜,文章很多的。
    至于缓存页面,在XXX.aspx页面中加入这么一句
    <%@ OutputCache Duration="60" VaryByParam="id" %>
    60是缓存时间,VaryByParam是指按参数,如果有多个参数,之间用分号分隔,
    如果不考虑参数,整页面缓存,则也要指定VaryByParam, 为"none",因为当xxx.asp传过来后,最终还会转换成XXX.aspx?id=xxx,
    所以要在XXX.aspx页面中指定根据id缓存
      

  7.   

    问题我已经解决,谢谢其实很简单,根本不用这些,直接用MS提供的 System.Web.IhttpHandler 
    我明天把代码发上来,太简单不过了,以前都需要写,现在直接用一个头请求转换就OK
    Microsoft is great,i love microsoft
      

  8.   

    step 1:
    run visual web developer 2005
    new file,greate class file(vb)source code(test):
    Import System
    Import System.Web
    NameSpace MicrosoftAspx
      Public Class TestMsAspx   public sub new()
        'init
       end sub()
       implements IhttpHandler
       pubic sub ExecuteCode(context as HttpContext) Implements IhttpHandler.ProcessRequest
       dim CurrentRequest as string=context.request.rawurl.tostring
    'get current request
    'set the access dirtory not have file
     CurrentReuqest=CurrentReuqest.remove(CurrentRequest.LastIndexOf("."),5)
    CurrentRequest=CurrentRequest.remove(0,CurrentRequest.lastIndexOf("/")+1)
    CurrentRequest=trim(CurrentRequest)
    'intro,you can't write CurrentRequest.trim()
    'CurrentRequest.trim<>trim(currentRequest)!!!!
    if (CurrentRequest)    then
    'here access database
    'then you can use httprequest remove read data,
    context.response.write("test success")
    context.response.write("< br />")
    context.response.write("you current request keyword value:")
    context.response.write(currentRequest)
    end if
       end sub'must compelte class inteface
      public readOnly Property IsReusable() as boolean implements IhttpHandler.IsReusable
      get
    'not support more
    return false
      end get
      end property
      End ClassEnd NameSpace
    save the file to site root diretory app_code file or execute vb editor to dll file save to bin folder
    step 2 create the web.config save as the same folder..................................
    web.config source<configuration><system.web><IhttpHandler><add type="MicrosoftAspx.MsTestAspx" Path="*.aspx" /></IhttpHandler></system.web></configuration>就这样就可以了,不需要设置任何文件,也不需要虚拟写文件,直接转交处理,实际根本连.aspx 的文件都没有,结果处理出来了,搜索是能搜索到的.MS的msdn动态具说大概思路是这样的.文件里面根本没有文件,直接用程序处理,然后就是.config 配置。我在国外的网站上看见的 
      

  9.   

    比如这样请求吧下面均为虚拟目录/news/default.aspx比如要动态访问
    /news/detail/
    像这样的文件名字
    /news/detail/123/default.aspx
    /news/detail/1234/default.aspx
    /news/detail/12345/default.aspx
    /news/detail/.../default.aspx
    /news/detail/dynamic/default.aspx/news/detail/123.aspx
    /news/detail/1234.aspx
    ............
    /news/detail/dynamic.aspx都是一回事,根本不需要缓冲文件,直接空的,用程序转交给 IhttpHandler 处理
      

  10.   

    建议不要用 htm,这样就没意思拉,要做就要做成MS一样的。
      

  11.   

    c# 和 VB一样的,只是声明和一小部分用法不一样