Sunday, March 11, 2012

web service method error when using a url rewriter

so I it doesn't have to do with IIS it had to do with url rewriter, when I remove the rewrite rules from my httpd.ini file the extention tool kit works can any one help here are my rewrite rules. does any one know a work around? or is this a bug ? would there be a rule that I could write to kick out of my httpd.ini file? or is there some thing that I can put to catch this in the formrewriter? maybe there is some thing to put some where else.

RewriteRule [^=]*/([a-z0-9_-]+)/? /CDIPortal\/PortalDirectoryEmulator.aspx\?dir=$1 [I,L]
RewriteRule [^=]*/([\w-]+)/([\w]+)(\.html) /CDIPortal\/PortalFileEmulator.aspx\?dir=$1&file=$2$3&type=partlist

here is my BrowserFile.browser file

<browsers
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
adapterType="CDIWebPage.FormRewriterControlAdapter" />
</controlAdapters>
</browser
</browsers>

and here is my formrewriter.cs

public class FormRewriterControlAdapter : System.Web.UI.Adapters.ControlAdapter
{
protected override void Render(HtmlTextWriter writer)
{
base.Render(new FormRewriter(writer));
}
}
/// <summary>
/// FormRewriter handels the url redirects and but the correct action on the page so post backs work .
/// </summary>
public class FormRewriter : HtmlTextWriter
{

public FormRewriter(HtmlTextWriter writer)
: base(writer)
{

InnerWriter = writer.InnerWriter;
}
public FormRewriter(System.IO.TextWriter writer)
: base(writer)
{
InnerWriter = writer;
}
public override void WriteAttribute(string name, string value, bool fEncode)
{
if (name == "action")
{
HttpContext context = HttpContext.Current;
if (context.Items["ActionAlreadyWritten"] == null)
{
if (context.Request.RawUrl.ToUpper().Contains("PORTALDIRECTORYEMULATOR.ASPX") || context.Request.RawUrl.ToUpper().Contains("PORTALFILEEMULATOR.ASPX"))
{
value = context.Request.CurrentExecutionFilePath + "?" + context.Request.QueryString;
}
else
value = context.Request.RawUrl;
context.Items["ActionAlreadyWritten"] = true;
}
}
base.WriteAttribute(name, value, false);
}
}

No comments:

Post a Comment