POST method generates a 405 error

Topics: Developer Forum
Dec 19, 2007 at 12:11 PM
Edited Dec 19, 2007 at 12:12 PM
I have a problem with UrlRewriting.
First i found that post generates 404 error, because the url witch was in action attribute of the form tag was pointing to a not existing file.
Microsoft suggests is to remove action attribute.,
But removing o rewriting action attribute as in following code generates 405 error:
protected override void Render(HtmlTextWriter writer)
if (!string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables"HTTP_X_REWRITE_URL"))
string sVirURL = HttpContext.Current.Request.ServerVariables"HTTP_X_REWRITE_URL";
RewriteFormHtmlTextWriter oWriter = new RewriteFormHtmlTextWriter(writer,sVirURL);

public class RewriteFormHtmlTextWriter : HtmlTextWriter
private readonly string _formAction;

public RewriteFormHtmlTextWriter(System.IO.TextWriter writer) : base(writer)
public override void RenderBeginTag(string tagName)
if (tagName.IndexOf("form") >= 0)
public RewriteFormHtmlTextWriter(System.IO.TextWriter writer, string action) : base(writer)
_formAction = action;
public override void WriteAttribute(string name, string value, bool fEncode)
if (name == "action")
value = _formAction;
base.WriteAttribute(name, value, fEncode);
Please help!!!!
Jan 8, 2008 at 1:52 PM
I don't get it.
Can you elaborate? clarify?
Jan 10, 2008 at 4:34 PM
I've found that problem was in IIS, Url to rewrite was something like /?param=value and i put /default.aspx?param=value and everything works fine
Thanks for the answer.