0

URL書き換えモジュールとしてintelligencia urlrewriterを使用しています。URLが書き換えられたときにのみ発生する非常に奇妙な問題が1つありますが、すべての書き換えられたページではなく、より楽しくするためです。

編集:何が問題なのかを伝えるのを忘れていましたboing boing . 問題は、Page_Load イベントが 2 回発生することです。

これは私のフォーム書き換えアダプターがどのように見えるかです:

using System;

System.Web.UI を使用します。System.Web の使用; System.Web.UI.WebControls を使用します。

public class FormRewriterControlAdapter : System.Web.UI.Adapters.ControlAdapter {

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{

    base.Render(new RewriteFormHtmlTextWriter(writer));

}

}

public class RewriteFormHtmlTextWriter : HtmlTextWriter {

public RewriteFormHtmlTextWriter(HtmlTextWriter writer)
    : base(writer)
{
    this.InnerWriter = writer.InnerWriter;
}

public RewriteFormHtmlTextWriter(System.IO.TextWriter writer)
    : base(writer)
{
    base.InnerWriter = writer;
}

public override void WriteAttribute(string name, string value, bool fEncode)
{

    // If the attribute we are writing is the "action" attribute, and we are not on a sub-control, 
    // then replace the value to write with the raw URL of the request - which ensures that we'll 
    // preserve the PathInfo value on postback scenarios 

    if ((name == "action"))
    {

        HttpContext Context = default(HttpContext);
        Context = HttpContext.Current;

        if (Context.Items["ActionAlreadyWritten"] == null)
        {

            // Because we are using the UrlRewriting.net HttpModule, we will use the 
            // Request.RawUrl property within ASP.NET to retrieve the origional URL 
            // before it was re-written. You'll want to change the line of code below 
            // if you use a different URL rewriting implementation. 

            value = Context.Request.RawUrl;

            // Indicate that we've already rewritten the <form>'s action attribute to prevent 
            // us from rewriting a sub-control under the <form> control 

            Context.Items["ActionAlreadyWritten"] = true;
        }

    }


    base.WriteAttribute(name, value, fEncode);

}

}

そして、これは私の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マークアップをチェックしました。

敬具、マーク

4

3 に答える 3

1

ルールでこの書き換えルールを使用している場合、この問題は解決されました。

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

ただし、すべての .css/.js/.jpg/... ルールの後にこのルールを使用することを忘れないでください。

于 2013-03-05T11:38:44.853 に答える
0

ついに私はそれを見つけました、それはリライトモジュールとは何の関係もありませんでした、これは問題を引き起こしました:

私のユーザーコントロールの1つで、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タグに置き換えたところ、すべてが正常に機能するようになりました。これを理解するのに少し時間がかかりました。あなたの頭痛の種を救うことができるといいのですが。

敬具

于 2010-02-18T19:10:43.510 に答える
0

複数の page_loads を検索しているこの投稿を見つけましたが、動的に作成された Image を使用して動的に作成された CollapsePanel を使用すると問題が発生しました。ImageUrl をデフォルトの画像に設定することで、問題は解決しました。

header.Controls.Add( new Image
{
    ID = string.Format( "headerImage_{0}",  panelId ),
    EnableViewState = false,
    ImageUrl = "~/Images/collapse.jpg"
} );
于 2010-09-03T10:16:48.323 に答える