Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET具有URL重写的多页面加载事件_Asp.net_Postback_Rewrite_Pageload - Fatal编程技术网

ASP.NET具有URL重写的多页面加载事件

ASP.NET具有URL重写的多页面加载事件,asp.net,postback,rewrite,pageload,Asp.net,Postback,Rewrite,Pageload,我使用intelligencia urlrewriter作为我的url重写模块。我有一个非常奇怪的问题,只有当url被重写时才会发生,但为了让它更有趣,不是在所有重写的页面上 编辑:忘了告诉你问题出在哪里了。问题是我的页面加载事件被触发了2次 这是我的表单重写适配器的外观: using System; 使用System.Web.UI; 使用System.Web; 使用System.Web.UI.WebControl 公共类FormRewriterControlAdapter:System.We

我使用intelligencia urlrewriter作为我的url重写模块。我有一个非常奇怪的问题,只有当url被重写时才会发生,但为了让它更有趣,不是在所有重写的页面上

编辑:忘了告诉你问题出在哪里了。问题是我的页面加载事件被触发了2次

这是我的表单重写适配器的外观:

using System;
使用System.Web.UI; 使用System.Web; 使用System.Web.UI.WebControl

公共类FormRewriterControlAdapter:System.Web.UI.Adapters.ControlAdapter {

}

公共类RewriteFormHtmlTextWriter:HtmlTextWriter {

公共重写表单HtmlTextWriter(HtmlTextWriter)
:base(writer)
{
this.InnerWriter=writer.InnerWriter;
}
公共重写表单HtmlTextWriter(System.IO.TextWriter)
:base(writer)
{
base.InnerWriter=编写器;
}
公共重写void WriteAttribute(字符串名称、字符串值、布尔代码)
{
//如果我们正在编写的属性是“action”属性,并且我们不在子控件上,
//然后用请求的原始URL替换要写入的值-这确保我们
//在回发方案中保留PathInfo值
如果((名称=“操作”))
{
HttpContext=默认值(HttpContext);
Context=HttpContext.Current;
if(Context.Items[“ActionalReadyWrited”]==null)
{
//因为我们使用的是UrlRewriting.net HttpModule,所以我们将使用
//ASP.NET中的Request.RawUrl属性检索原始URL
//在重新编写之前。您需要更改下面的代码行
//如果使用不同的URL重写实现。
value=Context.Request.RawUrl;
//指示我们已经重写了的action属性以防止
//阻止我们重写控件下的子控件
Context.Items[“ActionalReadyWrited”]=true;
}
}
base.WriteAttribute(名称、值、代码);
}
}

这就是我的web.config的样子

        <!-- Here the double page_load occurs  --> 
    <rewrite url="~/car-parts/(\d+)/(.+)" to="~/Products.aspx?type=parts&amp;iid=$1&amp;cid=9" />
    <rewrite url="~/car-stereo/(\d+)/(.+)" to="~/Products.aspx?type=stereo&amp;iid=$1&amp;cid=10" />



    <!-- this is working correctly -->
     <rewrite url="~/car-parts/browse-by-type/(\d+)/(.+)/(\d+)/(\d+)" to="~/Browse.aspx?cid=9&amp;type=country&amp;countryid=$1&amp;p=$3&amp;filter=$4" />

我不知道该去哪里看了,我检查了我的html标记,因为我读到了可能导致这个问题的信息

亲切问候,,
Mark

最后我找到了它,它与重写模块无关,这就是导致问题的原因:

在我的一个用户控件中,我使用了updateprogress

    <asp:UpdateProgress runat="server" AssociatedUpdatePanelID="upNewsletter" DisplayAfter="0">
    <ProgressTemplate>
        <asp:Image runat="server" ID="imgLoading" ImageUrl="~/Images/Template/loading.gif" />
    </ProgressTemplate>
</asp:UpdateProgress>

现在问题就出在asp:Image标记中。我已经用一个普通的img标签替换了它,现在一切又恢复正常了。我花了一些时间来解决这个问题,我希望我能帮你减轻头痛


亲切问候

我在搜索多个页面加载时发现了这篇文章,但是我在使用动态创建的图像时遇到了问题。通过将ImageUrl填充到默认图像,问题得到了解决

header.Controls.Add( new Image
{
    ID = string.Format( "headerImage_{0}",  panelId ),
    EnableViewState = false,
    ImageUrl = "~/Images/collapse.jpg"
} );

当我在规则中使用此重写规则时,此问题已得到解决:

<rewrite url="^(/.+(\.gif|\.flv|\.swf|\.png|\.jpg|\.ico|\.pdf|\.doc|\.xls|\.css|\.zip|\.rar|\.js|\.xml|\.mp3)(\?.+)?)$" to="$1" processing="stop" />


但是请记住在所有的.css/.js/.jpg/…之后使用这个规则。。。规则。

你没有说一个非常奇怪的问题是什么。
header.Controls.Add( new Image
{
    ID = string.Format( "headerImage_{0}",  panelId ),
    EnableViewState = false,
    ImageUrl = "~/Images/collapse.jpg"
} );
<rewrite url="^(/.+(\.gif|\.flv|\.swf|\.png|\.jpg|\.ico|\.pdf|\.doc|\.xls|\.css|\.zip|\.rar|\.js|\.xml|\.mp3)(\?.+)?)$" to="$1" processing="stop" />