网站首页是 index.aspx,经过url rewrite后,输入index.html即可访问。但是当输入网站的地址时,如 http://www.netcourse.com/,后面一般是不显示文件名index.html的,这样提交表单,比如查询时,就会出现"无法显示网页,由于网页地址不正确,正在查找的网页无法显示。"的错误,而如果输入全部的文件地址,http://www.netcourse.com/index.html,则一切正常,应该如何处理这个问题呢?一般网站都有默认首页的,比如访问新浪,输入http://www.sina.com.cn,其实访问的是http://www.sina.com.cn/index.shtml,怎么办呢?

解决方案 »

  1.   

    设置IIS中网站中的"启用默认内容文档"中添加 index.html
      

  2.   

    问题的关键是提交表单,用了ActionlessForm.dll,可以在index.html里执行查询等操作,实际上是交给了index.aspx,可是因为直接输入网址时,地址栏里是不显示默认首页的文件名的,这样的情况下就会出错,除非手动在手面加上index.html!
      

  3.   

    你是通过HttpModule进行RewritePath的吗?是不是verb不是用*或者忘记了添加POST?如果有,应该POST也进行RewritePath,那应该没问题的。我最近也给ASP.NET的RewritePath弄得很烦,发觉这个RewritePath太不好用了。ASP.NET内部很多对象,当他们需要获取所在的Page的地址以及实际运行文件的物理路径时,都会通过不同的方式获取,而我们没办法改变这些行为。
      

  4.   

    是用的微软的url rewrite控件.
      

  5.   

    你的虚拟目录的属性中查看下默认的页面设置中是否有index.html这样的,如果没有添加上就OK了
      

  6.   

    UrlRewriter组件中带的ActionlessForm,里面带例子的
      

  7.   

    ActionlessForm 不会影响 post检查你的配置
      

  8.   

    因为IIS首先检查是不是存在INDEX.HTML这个文件
    由于你是把INDEX.ASP映射上去的,并不存在这个文件 所以会报找不到文件
    你可以在首页所在目录下添加一个名为index.html的空文件,这样就解决了默认文件不存在的问题这个在URL REWRITER的文档里都写了...明显没有仔细读文档
      

  9.   

    很简单,写一个dll就可以了。编译成 dllusing System;
    using System.Configuration;
    using System.IO;
    using System.Web;
    using System.Web.UI;
    namespace ActionlessForm
    {
    /// <summary>
    /// The Form class extends the HtmlForm HTML control by overriding its RenderAttributes()
    /// method and NOT emitting an action attribute.
    /// </summary>
    public class Form : System.Web.UI.HtmlControls.HtmlForm
    {
    /// <summary>
    /// The RenderAttributes method adds the attributes to the rendered &lt;form&gt; tag.
    /// We override this method so that the action attribute is not emitted.
    /// </summary>
    protected override void RenderAttributes(HtmlTextWriter writer)
    {
    // write the form's name
    writer.WriteAttribute("name", this.Name);
    base.Attributes.Remove("name"); // write the form's method
    writer.WriteAttribute("method", this.Method);
    base.Attributes.Remove("method"); // remove the action attribute
    base.Attributes.Remove("action"); // finally write all other attributes
    this.Attributes.Render(writer); if (base.ID != null)
    writer.WriteAttribute("id", base.ClientID);
    } }
    }
    使用:<%@ Register TagPrefix="ZDIL1" Namespace="ActionlessForm" Assembly="ActionlessForm"%><ZDIL1:FORM id="Form1" runat="server" method="post">........</ZDIL1:FORM>ok了。
      

  10.   

    抱歉,没仔细审题我的首页里的查询(提交的部分)都是放在iframe里面的。参看 http://demo.daqingnet.com/首页本身没有提交的功能,而是通过首页里的 iframe里的页面来实现的。比如会员登录,搜索等页面。
      

  11.   

    我用的就是ActionlessForm 在地址栏显示了全部文件名的时候,http://www.net.com/index.html,不会报错,如果没有显示(http://www.net.com)则会报错,我已经按照上面说的,建立了一个index.html的空文件,可是还是报错,为什么?
      

  12.   

    看看是不是有类似这种代码
    <form action="?xx=x1"........
    如果有把action="....改成你真实的提交页面具体地址。
      

  13.   

    RewriterTester里面的ListProductsByCategory.aspx如果设为默认首页,那么点击任何按纽的时候,也会出现同样的情况,微软的示例都如此,如何办??难道不设置默认首页?或者默认首页设置为动态的,其它的设置为静态的。
      

  14.   

    skm:form 中加入action=""根本没有用
      

  15.   

    已经搞定了,加入
    <skm:Form method="post" runat="server" id="F1"  onsubmit=go()>function go(){
    //alert("ok");
    document.F1.action="index.html";
    document.F1.submit();
    }即可,看来,某些问题上,求人不如求己啊!!!还是谢谢大家的帮助