当前位置 : 主页 > 网络编程 > PHP >

.net 中URL 重写post提交后的地址变为了原地址问题的解决

来源:互联网 收集:自由互联 发布时间:2023-09-07
.net 中URL 重写post提交后的地址变为了原地址 让Page类继承OLPage 类就可以了,如:public partial class Bottom : gcy.Utility.OLPage { protected void Page_Load(object sender, EventArgs e) { } }-------------------------
.net 中URL 重写post提交后的地址变为了原地址
让Page类继承OLPage 类就可以了,如:public partial class Bottom : gcy.Utility.OLPage
{
protected void Page_Load(object sender, EventArgs e)
{ }
}-----------------------------------------------------------------------
gcy.Utility namespace :using System;
using System.IO;
using System.Web;
using System.Web.UI;
namespace gcy.Utility
{
public class OLPage : Page
{
public OLPage()
{

}
protected override void Render(HtmlTextWriter writer)
{
if (writer is System.Web.UI.Html32TextWriter)
{
writer = new FormFixerHtml32TextWriter(writer.InnerWriter);
}
else
{
writer = new FormFixerHtmlTextWriter(writer.InnerWriter);
}
base.Render(writer);
}
} internal class FormFixerHtml32TextWriter : System.Web.UI.Html32TextWriter
{
private string _url; // 假的URL
internal FormFixerHtml32TextWriter(TextWriter writer):base(writer)
{
_url = HttpContext.Current.Request.RawUrl;
}
public override void WriteAttribute(string name,string value,bool encode)
{
if (_url != null && string.Compare(name,"action",true) == 0)
{
value = _url;
}
base.WriteAttribute(name,value,encode);
}
}
internal class FormFixerHtmlTextWriter : System.Web.UI.HtmlTextWriter
{
private string _url;
internal FormFixerHtmlTextWriter(TextWriter writer):base(writer)
{
_url = HttpContext.Current.Request.RawUrl;
}
public override void WriteAttribute(string name,string value,bool encode)
{
if (_url != null && string.Compare(name,"action",true) == 0)
{
value = _url;
}
base.WriteAttribute(name,value,encode);
}
}}
上一篇:给select控件在指定位置插入option(javascript)
下一篇:没有了
网友评论