0 Comments

If you are using URL rewriting, the ASP.NET HTML form tag doesn't support it. You have to override the form tag in order to make it work. It was a bug in ASP.NET 1.x and still haven't been fixed in 2.0. Here is the class I use when doing URL rewriting.

using System;
using System.Web;
using System.Web.UI;

public class Form : System.Web.UI.HtmlControls.HtmlForm
{
 protected override void RenderAttributes(HtmlTextWriter writer)
 {
  writer.WriteAttribute("name", this.Name);
  base.Attributes.Remove("name");

  writer.WriteAttribute("method", this.Method);
  base.Attributes.Remove("method");

  this.Attributes.Render(writer);

  writer.WriteAttribute("action", HttpUtility.HtmlEncode(Context.Request.RawUrl));
  base.Attributes.Remove("action");

  writer.WriteAttribute("onsubmit", "if (typeof(WebForm_OnSubmit) == 'function') return WebForm_OnSubmit();");
  base.Attributes.Remove("onsubmit");

  if (base.ID != null)
  writer.WriteAttribute("id", base.ClientID);
 }
}