Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create the following control adapter to rewrite the form tag with the for the action attribute. I used this a ASP.NET 2.0 app in conjunction with the <a href="http://urlrewriter.net/" rel="nofollow noreferrer">Intelligencia</a> url rewriter. I got it from this <a href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx" rel="nofollow noreferrer">blog post from the Gu</a>.</p> <p>Put this class in your App_Code folder: </p> <pre><code>using System.IO; using System.Web; using System.Web.UI; public class FormRewriterControlAdapter : System.Web.UI.Adapters.ControlAdapter { protected override void Render(HtmlTextWriter writer) { base.Render(new RewriteFormHtmlTextWriter(writer)); } } public class RewriteFormHtmlTextWriter : HtmlTextWriter { public RewriteFormHtmlTextWriter(TextWriter writer) : base(writer) { base.InnerWriter = writer; } public RewriteFormHtmlTextWriter(HtmlTextWriter writer) : base(writer) { this.InnerWriter = writer.InnerWriter; } 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")) { if (HttpContext.Current.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 = HttpContext.Current.Request.RawUrl; // Indicate that we've already rewritten the &lt;form&gt;'s action attribute to prevent // us from rewriting a sub-control under the &lt;form&gt; control HttpContext.Current.Items["ActionAlreadyWritten"] = true; } } base.WriteAttribute(name, value, fEncode); } } </code></pre> <p>Then, create this .browser file in your App_Browsers folder:</p> <pre><code>&lt;browsers&gt; &lt;browser refID="Default"&gt; &lt;controlAdapters&gt; &lt;adapter controlType="System.Web.UI.HtmlControls.HtmlForm" adapterType="FormRewriterControlAdapter" /&gt; &lt;/controlAdapters&gt; &lt;/browser&gt; &lt;/browsers&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload