2011-04-21 85 views
1

之間的IIS7重定向,我們有幾個虛擬目錄。在IIS7中,這些被稱爲「應用程序」,它們都具有相同的應用程序池,以傳統管道模式運行。我們的asp.net應用程序中的虛擬目錄

  • www.webapp.com/example1
  • www.webapp.com/example2

他們都指向同一個物理目錄,比如C:\ web應用。唯一的區別是它們每個都有一個底層的虛擬目錄指向不同的CSS文件夾,位於C:\ webapp \ styles \(例如C:\ webapp \ styles \ example1 \ base.css等)

我們使用表單身份驗證和內置的成員資格提供程序。我們遇到的問題是:

當用戶瀏覽www.webapp.com/example1/page.aspx並點擊重定向到www.webapp.com/example2/otherpage.aspx的鏈接時,用戶是而是重定向到www.webapp.com/example2/login.aspx。看起來好像會話過期了。

我們並不真正知道在哪裏尋找解決方案,任何指針都非常感謝! 在此先感謝! 斯泰恩

回答

1

我們找到了解決辦法,所以我想我會與SO社會共享:

組通過反射AppDomainAppId爲固定值(在這種情況下的applicationName):

Globals.asax。 cs:

protected void Application_Start(object sender, EventArgs e) 
    { 
     // make sure all set the same AppDomainAppId 
     FieldInfo runtimeInfo = typeof(HttpRuntime).GetField("_theRuntime", BindingFlags.Static | BindingFlags.NonPublic); 
     if (runtimeInfo == null) return; 
     HttpRuntime theRuntime = (HttpRuntime)runtimeInfo.GetValue(null); 
     if (theRuntime == null) return; 
     FieldInfo appNameInfo = typeof(HttpRuntime).GetField("_appDomainAppId", BindingFlags.Instance | BindingFlags.NonPublic); 
     if (appNameInfo == null) return; 
     var appName = (String)appNameInfo.GetValue(theRuntime); 
     if (appName != "applicationName") appNameInfo.SetValue(theRuntime, "applicationName"); 
    } 
相關問題