我構建了一個託管在ASP.NET Web App上的Silverlight應用程序。 /啓用IIS7/SSL的網站。
爲了安全起見,我把我的Silverlight頁面一個成員文件夾中的ASP.NET Web應用程序,並限制來自匿名用戶的訪問。(見下面的web.config)ASP.NET登錄頁面重定向問題
當用戶嘗試訪問成員文件夾下的頁面,他們被重定向到https://www.ssldemo.com/authenticationtest/login.aspx。 (請參閱下面的web.config) (我已將www.ssldemo.com映射到127.0.0.1)。 爲了安全起見,我在login.aspx中切換到HTTPS,並在驗證後返回到HTTP。下面的代碼爲login.aspx.cs,下面是 。
protected void Page_Load(object sender, EventArgs e)
{
LoginControl.LoggedIn += new EventHandler(LoginControl_LoggedIn);
}
void LoginControl_LoggedIn(object sender, EventArgs e)
{
//for going to ReturnURL & switching back to HTTP
string serverName = HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]);
string returnURL = Request["ReturnURL"];
Response.Redirect(ResolveClientUrl("http://" + serverName + returnURL));
}
的問題是,當我部署另一應用http://www.ssldemo.com/authenticationtest/members/AnotherApplication/ 和開放http://www.ssldemo.com/authenticationtest/members/AnotherApplication/default.aspx, 用戶重定向到https://www.ssldemo.com/authenticationtest/login.aspx?ReturnUrl=%2fauthenticationtest%2fmembers%2fanotherapplication%2fdefault.aspx。 但是即使當我在登錄頁面輸入正確的憑證時,我也會被重定向到,而不是ReturnUrl。當我看着小提琴手時,它說'302物體移到這裏了。'
謝謝您的閱讀!任何輸入將不勝感激。
<configuration>
<connectionStrings>
<add name="CompanyDatabase" connectionString="Data Source=192.168.0.2;Initial Catalog=SomeTable;User ID=Username;[email protected]" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms slidingExpiration="true" timeout="15"
loginUrl="https://www.ssldemo.com/authenticationtest/login.aspx"
defaultUrl="~/Members/Default.aspx"
>
</forms>
</authentication>
<!--Custom Membership Provider-->
<membership defaultProvider="MyMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<clear />
<add name="MyMembershipProvider"
type="AuthenticationTest.Web.MyMembershipProvider"
connectionStringName="CompanyDatabase"
applicationName="AuthenticationTest.Web"/>
</providers>
</membership>
</system.web>
<!--securing folders-->
<location path="Members">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>