基本概述......
我在iis中设置了网站...
- “mysite”(wwwroot \ mysite)下有2个虚拟目录应用程序
- “上传”(\ uploadfiles)
- “app”(wwwroot \ myapp)
我还有一个子域,在iis中设置为不同的站点...
- “beta.mysite”(wwwroot \ mysitebeta)下有2个虚拟目录
- “上传”(\ uploadfiles)
- “app”(wwwroot \ myappbeta)
子域名正常工作....我可以输入https://beta.mysite.com/app ...它会将测试版网站日志完美地发现....问题是,当我点击任何一个创建回发的按钮...它将恢复为https://www.mysite.com/app ...
所有链接都显示其文件的正确相对路径....如果我输入https://beta.mysite.com/app/dir/page.aspx ...它实际上将转到测试网站上的该页面,所有链接都将转到正确的位置...它只是那些杀了我的回发......
答案 0 :(得分:1)
您是否尝试过为这两个网站设置不同的应用程序池?看起来它正在尝试“聪明”,并得出结论,这两个虚拟目录实际上是同一个网站。
如果所有其他方法都失败了,您可以在ASP.NET手动生成的FORM-tag中重写回发URL。使用App_Browsers文件和ControlAdapter可能是最干净的方法。
我有一个这样的ControlAdapter实现的示例,但它旨在使用URL重写来防止在回发时恢复到实际的幕后URL。但是,我认为它可以解决您的问题
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 文件:
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.HtmlControls.HtmlForm" adapterType="FormRewriterControlAdapter" />
</controlAdapters>
</browser>
</browsers>