本帖最后由 amwihiud 于 2011-02-28 21:00:45 编辑

解决方案 »

  1.   

    string newUrl;
    if(url.Contains(".aspx"))
    newUrl =url.Replace(".aspx",".html"); //将aspx后缀转换为html后缀,实现伪静态。
    else
    newUrl=url;
    目录设置默认文档或context.writepath
      

  2.   

    我就是不想写扩展名....
    想把网页伪装成目录的形式.比如http://video.sina.com.cn/movie/detail/zhb这样的地址.或是想转成http://test.xiaoyangstudio.com/do.dll这样的地址..
      

  3.   

    在制作网站的过程中经常要用到AJAX请求...为了这些AJAX请求去新建一个页面又感觉麻烦..
    我的技术主管用了个方法.可以使用类似于
    http://www.feiku.com/do.dll?n=GetCurrentUser&t=Cnaws.Web.Sites,Cnaws.Web
    这样的链接去请求一个AJAX回应..
    我也想实用这样的效果.
    昨天使用了这样的方法private void application_BeginRequest(object sender, EventArgs e) {
                //重写URL
                HttpContext context = (sender as HttpApplication).Context;
                string FullURL = context.Request.Url.ToString();
                if (FullURL.Contains("/run.dll?")) {
                    context.Response.End();
                }
            }
     public void application_EndRequest(object sender, EventArgs e) {
                HttpApplication application = sender as HttpApplication;
                HttpContext context = application.Context;
                HttpResponse response = context.Response;
                if (context.Request.Url.ToString().Contains("/run.dll?")) {
                    string className = context.Request.QueryString["in"];
                    string functionName = context.Request.QueryString["run"];
                    //context.Response.Write("命名空间:" + className + ",函数名:" + functionName);
                    string[] paraName = context.Request.Form.AllKeys ;
                    //context.Response.Write("参数名:" + paraName + ",值" + paraValue);
                    //context.Response.Write("\n\r");
                    try {
                        Type tp = Type.GetType(className, false, true);
                        MethodInfo ma = tp.GetMethod(functionName);
                        string[] inParam = new string[ma.GetParameters().Length];
                        int ParamIndex = 0;
                        foreach (ParameterInfo param in ma.GetParameters()) {
                            for (int i = 0; i < paraName.Length; i++) {
                                if (paraName[i] == param.Name) {
                                    inParam[ParamIndex] = context.Request.Form[i];
                                    ParamIndex++;
                                }
                            }
                        }
                        context.Response.Write(ma.Invoke(null, inParam).ToString());
                    } catch(Exception ex) {
                        context.Response.Clear();
                        context.Response.Write(ex.ToString());
                    }
                }
            }
    在windows2003+vs2008+IIS6.0的情况下是可行.
    但是回到家又不行了..而且传上我的空间也不行..我估计这个问题和我上面的问题的原因是一样的..
      

  4.   

    用HttpModule与UrlReWriter有什么区别啊 用UrlReWriter很方便啊,只需改一下正则表达式
      

  5.   

    其实我也是想用正则的方式去改写URL..但是我想用自己写的东西.不想用UrlReWriter..因为我还要附加一些别的功能
      

  6.   

    会不会是因为ISAPI没有接管非.aspx和.html的请求的原因..?
    XP的IIS5里没有IIS6那样的设置...
    是不是默认只能接管.aspx和.html  一定要装了IIS6才可以接受非.aspx和.html的URL请求.?