2011-11-01 201 views
4

我最近將一個項目從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 
+0

您是否在應用程序中使用重寫url? – sikender

+0

no AhsenB

+0

你有沒有解決過這個問題?我現在有這個問題。 –

回答

1

只是想檢查是否安裝了.NET 4.0完全安裝。與IIS6一樣,.NET 4.0可能會出現一些奇怪的錯誤。

即使您已經安裝並在IIS中將其設置爲正確的應用程序池,但它仍然無法正常工作。

請使用以下指南以確保.NET 4.0的.dll已註冊,否則您將以部分工作應用程序結束。

http://johan.driessen.se/posts/getting-an-asp.net-4-application-to-work-on-iis6

+0

我不認爲這是一個問題,你可以在上面看到更多的信息。 – AhsenB

1

不知道有關在配置設置默認網址,從來沒有試過之前。我們始終將其設置在應用程序的IIS屬性中。也許檢查一下?

您可以通過檢查:

右鍵單擊在IIS管理器應用程序,單擊屬性,單擊「文檔」選項卡,勾選「啓用默認內容頁」複選框,並確保正確的頁面是列表框。

+0

不過,已經完成了,但仍然沒有去感謝,但。 – AhsenB

1

我想象在ASP.NET 4中引入的無擴展url功能會導致一些問題。 Thomas Marquardt在禁用此功能here上有博客文章。

試試這個,希望你的困境會消失。

+0

對不起,我也試過這個,但沒有去做其他事情必須做到這一點。再次,這與3.5完美... – AhsenB