I recently upgraded the project from 3.5 to 4.0, everything went fine, except that ReturnUrl does not do what it uses. Project Structure:
All projects - asp.net 4.0:
1. (root): http://example.com
2. (Project1) http://example.com/Project1
3. (MyProject) http://example.com/MyProject <- Virtual directory. This project has problems.
Here is my web.config:
<?xml version="1.0"?> <configuration> <configSections> ... </configSections> <system.net> <mailSettings> <smtp from=" support@localhost "> <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"/> <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" 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> <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>
The only temp fix that really helps is Global.asax.cs
protected void Application_BeginRequest(object sender, EventArgs e) { if (Request.AppRelativeCurrentExecutionFilePath == "~/") HttpContext.Current.RewritePath("Home.aspx"); }
However, with IE 8/9, if I go to http://example.com/MyProject , it will not work, but if I do: http://example.com/MyProject/ (added /) it works. Shouldn't defaultUrl be redirected to the main application? And why does returnUrl point to http://example.com/MyProject/Login.aspx?ReturnUrl=%2fMyProject%2f
I searched google and even this site with countless solutions, but no one seems to have resolved this for me. Perhaps due to the fact that this project is in a subdirectory of other projects and has a conflict with web.config.
By the way, anonymous access is included in authentication methods in IIS, and nothing is verified.
I donβt know what else could be, it drops it. I tried to make Home.aspx the main page or Login.aspx does not matter.
Additional Information:
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
also:
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