时间:2021-07-01 10:21:17 帮助过:19人阅读
输出的属性为form标记的action属性,则将其值替换为重写后的虚假URL
using System;
using System.IO;
using System.Web;
using System.Web.UI;
namespace Openlab.Controls
...{
/**//// <summary>
/// 页面基类
/// </summary>
public class OLPage : Page
...{
public OLPage()
...{
}
Render#region Render
/**//// <summary>
/// 重写默认的HtmlTextWriter方法,修改form标记中的value属性,使其值为重写的URL而不是真实URL。
/// </summary>
/// <param name="writer"></param>
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);
}
#endregion
}
FormFixers#region FormFixers
FormFixerHtml32TextWriter#region FormFixerHtml32TextWriter
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)
...{
// 如果当前