Upgrading asp.net 3.5 to 4.0 IIS6 ReturnURL Errors

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 Mail setup--> <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"/> <!--<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> 

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 
+4
source share
3 answers

I just want to check that you have .Net 4.0 installed. As with IIS6, there may be some weird bugs with .Net 4.0.

Even if you installed it and configured it in IIS as the correct application pool, it still does not work.

Use the following manual to make sure that the .dll for .Net 4.0 is registered, otherwise you will get a partially working application.

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

+1
source

Not sure about setting the default url in the config, never tried this before. We always set it in the IIS properties for the application. Perhaps check this out?

You can check this out:

Right-click the application in IIS Manager, select properties, go to the "Documents" tab, select the "Enable default content page" checkbox, and make sure that the list contains the correct page.

+1
source

I assume that the non-extension extension feature introduced in ASP.NET 4 is causing some problems. Thomas Marquardt has a blog post about disabling this feature here .

Give this a try and hopefully your troubles disappear.

+1
source

Source: https://habr.com/ru/post/1379085/


All Articles