我最近將一個項目從3.5升級到4.0,除了ReturnUrl沒有做它的用途之外,一切都變得很好。該項目的結構:asp.net 3.5升級到4.0 IIS6 ReturnURL問題
所有的項目都是asp.net 4.0:
1(根):http://example.com
2.(PROJECT1)http://example.com/Project1
3.(MyProject的)http://example.com/MyProject < - 虛擬目錄。這個項目有問題。
這裏是我的web.config:
<?xml version="1.0"?>
<configuration>
<configSections>
...
</configSections>
<!--System.net Mail setup-->
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="localhost" port="25" defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>
<appSettings>
...
<add key="loginUrl" value="Login.aspx" />
<add key="defaultUrl" value="Home.aspx" />
</appSettings>
<connectionStrings>
<clear/>
<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=aspnetdb_test;Integrated Security=True" providerName="System.Data.SqlClient"/>
...
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
...
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
</compilation>
<customErrors mode="Off"/>
<!--<customErrors mode="On" defaultRedirect="ErrorPage.aspx">
<error statusCode="403" redirect="PageNotFound.aspx"/>
<error statusCode="404" redirect="PageNotFound.aspx"/>
</customErrors>-->
<pages enableSessionState="true" validateRequest="false" enableEventValidation="true" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<controls>
...
</controls>
</pages>
<httpHandlers>
...
</httpHandlers>
<httpModules>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
...
</httpModules>
<httpRuntime maxRequestLength="458292"/>
<authentication mode="Forms">
<!--<forms loginUrl="~/Login.aspx" defaultUrl="~/Home.aspx" protection="All" timeout="60" name=".ASPXFORMSAUTH" requireSSL="false" slidingExpiration="true" cookieless="UseCookies" enableCrossAppRedirects="false"/>-->
<forms loginUrl="Login.aspx" protection="All" timeout="60" name=".ASPXFORMSAUTH" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="Home.aspx" cookieless="UseCookies" enableCrossAppRedirects="false" />
</authentication>
<authorization>
<allow roles="Admin"/>
<allow roles="Student"/>
<allow roles="Test"/>
<deny users="*"/>
<deny users="?"/>
</authorization>
<machineKey validationKey="..." decryptionKey="..." validation="SHA1"/>
<membership defaultProvider="MembershipProvider">
<providers>
...
</providers>
</membership>
<roleManager enabled="true" defaultProvider="RoleManagerSqlProvider">
<providers>
...
</providers>
</roleManager>
<httpCookies httpOnlyCookies="true"/>
<sessionState cookieless="AutoDetect"/>
<trace enabled="false"/>
</system.web>
<location path="Home.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<location path="Login.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="Logout.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="AJAXServices">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="SignIn.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="ResetPassword.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="About.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="ErrorPage.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="PageNotFound.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<location path="Assets">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
...
</modules>
<handlers>
...
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
</assemblyBinding>
</runtime>
</location>
</configuration>
唯一的臨時修復,做幫助是Global.asax.cs中
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.AppRelativeCurrentExecutionFilePath == "~/")
HttpContext.Current.RewritePath("Home.aspx");
}
然而,隨着IE 8/9,如果我瀏覽到http://example.com/MyProject它失敗,但如果我這樣做: http://example.com/MyProject/(增加了/)它的工作原理。是不是defaultUrl假設重定向到主應用程序?爲什麼returnUrl指向 http://example.com/MyProject/Login.aspx?ReturnUrl=%2fMyProject%2f
我已經搜索谷歌,甚至這個網站有無數的解決方案,但似乎沒有解決它對我來說。也許是由於這個項目在其他項目的子目錄中,並且與web.config有衝突。
順便說一句在IIS中的身份驗證方法啓用匿名訪問被檢查,沒有其他檢查。
我不知道還有什麼可能會丟掉它。我試圖讓Home.aspx成爲主頁或Login.aspx並不重要。
附加信息:
C:\WINDOWS\system32>cscript IisExt.vbs /ListFile
Status/Extension Path
------------------------
0 C:\WINDOWS\system32\inetsrv\httpodbc.dll
1 C:\WINDOWS\system32\inetsrv\ssinc.dll
1 C:\WINDOWS\system32\inetsrv\asp.dll
1 C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll
1 C:\ColdFusion9\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll
0 *.exe
0 C:\WINDOWS\system32\inetsrv\httpext.dll
0 *.dll
1 c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll
1 C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
另外:
C:\WINDOWS\microsoft.net\Framework64\v4.0.30319>aspnet_regiis -lk
W3SVC/ 4.0.30319.0
W3SVC/1971902459/root/ 4.0.30319.0
W3SVC/1971902459/root/Project1/ 4.0.30319.0
W3SVC/1971902459/root/MyProject/ 4.0.30319.0
W3SVC/53091907/root/ 4.0.30319.0
您是否在應用程序中使用重寫url? – sikender
no –
AhsenB
你有沒有解決過這個問題?我現在有這個問題。 –