我用的是虚拟主机,这种情况下肯定不可能让我去配置IIS和安装插件~~
在这种情况下asp.net 2.0能实现URL重写吗?

解决方案 »

  1.   

    2.0最简单的办法就是在配置文件中 
      <system.web>
    下加入 urlMappings
      

  2.   

    直接在Web.config文件的  <system.web> 
    下添加如下代码
    如:<urlMappings enabled="true">
          <clear/>
          <add url="~/default.aspx" mappedUrl="~/news.aspx"/>
    </urlMappings>
      

  3.   

    1. Add a global.asax file to your project:
    <%@ Application Language="C#" %>
    <script language="C#" runat="server">
    protected void Application_BeginRequest(object sender,
                                            EventArgs e)
    {
                string[] s = Context.Request.Url.AbsoluteUri.Split('/');
                if (s.Length > 0) {
                    string q = s[s.Length - 1];
                      Context.RewritePath("WebForm4.aspx?a=" + q);
                }
              
      
    }</script>
      For the simplicity I hardcoded the rewrited path.
    2. In WebForm4.aspx add following code to test:
       protected void Page_Load(object sender, EventArgs e)
            {
                if (Request.QueryString["a"] != null) {
                    Response.Write(Request.QueryString["a"]);
                }
            }
    3.http://localhost:port/aaa
      

  4.   

    当然IIS配置肯定有影响。设置的不好那就没办法。