tags:

views:

78

answers:

1

basic overview...

i have a site setup in iis...
- "mysite" (wwwroot\mysite) under that there are 2 virtual directory applications
- "uploads" (\uploadfiles)
- "app" (wwwroot\myapp)

I also have a subdomain that is set up as a different site in iis...
- "beta.mysite" (wwwroot\mysitebeta) under that there are 2 virtual directory
- "uploads" (\uploadfiles)
- "app" (wwwroot\myappbeta)

the sub domain is working fine.... i can type in https://beta.mysite.com/app ... and it brings up the beta site log in perfectly fine.... the problem is, when i click on any of the buttons that create a post back... it reverts to https://www.mysite.com/app...

all of the links display the correct relative path to their files.... and if i type in https://beta.mysite.com/app/dir/page.aspx... it will actually go to that page on the beta site, all the links are going to the right spots... its just the postbacks that are killing me...

+1  A: 

Have you tried setting a different application pool for these two websites? Looks like it's trying to be "smart" and concludes that the two virtual directories are actually the same website.

If all else fails, you could rewrite the postback URL in the FORM-tag that ASP.NET generates manually. Using an App_Browsers file and a ControlAdapter are probably the cleanest way of doing that.

I have an example of such a ControlAdapter implementation, though it is intended to work with URL rewriting to prevent reverting to the actual behind-the-scenes URL on postback. However, I think it would work for your problem out-of-the-box

public class FormRewriterControlAdapter : System.Web.UI.Adapters.ControlAdapter 
{
 protected override void Render(HtmlTextWriter writer)
 {
  base.Render(new RewriteFormHtmlTextWriter(writer));
 }
}

public class RewriteFormHtmlTextWriter : HtmlTextWriter
{
 private const string contextItemKey = "FormActionWritten";

 public RewriteFormHtmlTextWriter(HtmlTextWriter writer) : base(writer)
 {
  InnerWriter = writer.InnerWriter;
 }

 public RewriteFormHtmlTextWriter(System.IO.TextWriter writer) : base(writer)
 {
  base.InnerWriter = writer;
 }

 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" && !HttpContext.Current.Items.Contains(contextItemKey))
  {
   // Use the Request.RawUrl property to retrieve the un-rewritten URL
   value = HttpContext.Current.Request.RawUrl;
   HttpContext.Current.Items[contextItemKey] = true;
  }

  base.WriteAttribute(name, value, fEncode);
 }
}

Form.browser file:

<browsers>
    <browser refID="Default">
     <controlAdapters>
      <adapter controlType="System.Web.UI.HtmlControls.HtmlForm" adapterType="FormRewriterControlAdapter" />
     </controlAdapters>
    </browser>
</browsers>
Thorarin
Tried a new app pool... no dice... The problem with re-writing things is that the beta will be used as a staging site for customer testing... i'm working with 40+ projects containing over 100 classes including custom controls...
Patrick
No need to rewrite anything, the above code should be all that's needed to fix the problem.
Thorarin