내 URL 재 작성 모듈로 intelligencia urlrewriter를 사용하고 있습니다. 나는 url이 재 작성 될 때만 발생하지만 재 작성된 모든 페이지가 아니라 더 재미있게 만드는 아주 이상한 문제가있다.ASP.NET URL 재 작성을 사용하여 여러 Page_Load 이벤트
편집 : 문제를 알려주십시오. 보잉 보우. 문제는 내 Page_Load 이벤트가 두 번 발생한다는 것입니다.
이처럼 내 양식 재 작성 어댑터가 모습입니다 :
using System;
가 System.Web.UI를 사용하는; using System.Web; using System.Web.UI.WebControls;
공용 클래스 FormRewriterControlAdapter : System.Web.UI.Adapters.ControlAdapter {
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
base.Render(new RewriteFormHtmlTextWriter(writer));
}
}
공용 클래스 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);
}
}
안 D이 내 Web.config의이
<!-- Here the double page_load occurs -->
<rewrite url="~/car-parts/(\d+)/(.+)" to="~/Products.aspx?type=parts&iid=$1&cid=9" />
<rewrite url="~/car-stereo/(\d+)/(.+)" to="~/Products.aspx?type=stereo&iid=$1&cid=10" />
<!-- this is working correctly -->
<rewrite url="~/car-parts/browse-by-type/(\d+)/(.+)/(\d+)/(\d+)" to="~/Browse.aspx?cid=9&type=country&countryid=$1&p=$3&filter=$4" />
처럼 내가이이 문제를 나오긴 수 읽은 이후로 더 이상보고 할 생각은, 난 내 HTML 마크 업을 확인하지가 모습입니다.
종류의 안부 마크
당신은 매우 이상한 문제가 무엇인지 말하지 않았습니다. –