在网上看了好多的关于伪静态的技术,好像都是要设置IIS,但是现在有一个问题就是服务器不在本地,有办法实现吗?

解决方案 »

  1.   

    在你的IIS上新建一个网站指向你的项目(你在服务器怎么建,这里也是一样的),然后再找到C:\WINDOWS\system32\drivers\etc\hosts,用文本打开添加一个192.168.1.2       www.hao.com(你计算机的IP,你新建网站的站点)
      

  2.   

    与服务器商联系
    context.rewriterpath重写路径
      

  3.   

    <?xml version="1.0"?><configuration>  <configSections>
        <section name="rewriter"  
                 requirePermission="false" 
                 type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
      </configSections>
      
      <system.web>
          
        <httpModules>
          <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
        </httpModules>
        
      </system.web>  <rewriter>
        <rewrite url="~/products/books.aspx" to="~/products.aspx?category=books" />
        <rewrite url="~/products/CDs.aspx" to="~/products.aspx?category=CDs" />
        <rewrite url="~/products/DVDs.aspx" to="~/products.aspx?category=DVDs" />
      </rewriter>  
      
    </configuration>  
      

  4.   

    http://www.chinaz.com/Program/.NET/0410H2112009.html
      

  5.   

    可以实现。其实就是重写url呀。原理就是当一个用户请求你的1.html地址,你的站点程序在处理这个请求之前将1.html地址改为了a.aspx?id=1。然后处理程序也就是a.aspx去执行就可以了。不修改iis或加载任何dll的方法当然可以,如下:
    1、 如何在请求前将地址1.html改成a.aspx?id=1呢。在Global.asax文件里的
    Application_BeginRequest方法里做就行了:void Application_BeginRequest(object sender, EventArgs e)
      {
        //URL重写
        string url = HttpContext.Current.Request.Path;
       int idx = url.IndexOf(".html");
       if (idx != -1)
        {
            int lastidx = url.LastIndexOf('/');
            HttpContext.Current.RewritePath(string.Concat(url.Substring(0, lastidx), "/a.aspx?id=", url.Substring(lastidx + 1, idx - lastidx - 1)));
        }
      }以上只是个示例,当然你可以把重写路径的方法写的非常复杂,例如支持正则表达式替换,支持缓存路径......你想怎么改都行。呵呵~