1

I'm keeping an ageing C# .NET MVC website going that I didn't write. Things have been fine but a strange thing has just happened:

When trying to run the project locally from Visual Studio 2017 using F5 it has suddenly loaded up Chrome and immediately redirects to the www.mywebsite.com address in that window rather than the usual localhost:64874 address.

I can't work out how to stop it redirecting to the live website. It never used to do this and the only thing that seems to have changed is that I was using a different web.config temporarily to connect to a different database and Visual Studio said

'The page cannot be run in debug mode because debugging is not enabled in the Web.config file. What would you like to do?'

and I checked 'Modify the Web.config file to enable debugging'.

Since then Chrome fires up the www.mywebsite.com and nothing I do can make it go back to running localhost - if I type the localhost:64874 address into the debug Chrome window it redirects to the www immediately.

I edited the web.config to 'debug="false"' and this makes it run but without debugging, which is kind of useless. As soon as I put it back to 'true' then I return to www.mywebsite.com.

I searched for 'www.mywebsite.com' and there isn't any mention of it in the entire codebase. There are no redirect rules setup anywhere I can see.

Any ideas? (I did look through similar questions but none of them were quite the same or solved the problem).

edited web.config below:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        <sectionGroup name="descriptionGroup">
          <section name="description" type="Objects.DescriptionSection" allowLocation="true" allowDefinition="Everywhere" />
        </sectionGroup>
      </configSections>
      <descriptionGroup>
        <description>
          <AboutUs description="about us" keywords="FUUUUU" />
          <ContactUs description="contact us" />
          <WWT description="wwt" />
          <WET description="wet" />
          <CookiePolicy description="cookie policy" />
          <Advertise description="advertise" />
        </description>
      </descriptionGroup>
      <connectionStrings>
        <add name="WaterPlain" connectionString="data source=tcp:123.123.123.123;initial catalog=mywebsite_partnership;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;" />
        <add name="mywebsiteDbEntities" connectionString="metadata=res://*/Models.mywebsiteDbModel.csdl|res://*/Models.mywebsiteDbModel.ssdl|res://*/Models.mywebsiteDbModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tcp:123.123.123.123;initial catalog=mywebsite_partnership;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        <add name="mywebsiteNews" connectionString="data source=tcp:123.123.123.123;initial catalog=mywebsite_News1;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;" />
        <add name="mywebsite_News1Entities" connectionString="metadata=res://*/Models.mywebsiteNews.csdl|res://*/Models.mywebsiteNews.ssdl|res://*/Models.mywebsiteNews.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tcp:123.123.123.123;initial catalog=mywebsite_News1;user id=sa;password=passwordRemoved;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        <add name="ProductPlain" connectionString="data source=tcp:123.123.123.123;initial catalog=mywebsite_PF_TEST;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;" />
        <add name="mywebsite_PF_TESTEntities" connectionString="metadata=res://*/Models.Products.csdl|res://*/Models.Products.ssdl|res://*/Models.Products.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tcp:123.123.123.123;initial catalog=mywebsite_PF_TEST;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        <add name="CustomMembershipPlain" connectionString="data source=tcp:123.123.123.123;initial catalog=RegisteredUsers;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;" />
        <add name="RegisteredUsersEntities" connectionString="metadata=res://*/Models.CustomMembership.csdl|res://*/Models.CustomMembership.ssdl|res://*/Models.CustomMembership.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tcp:123.123.123.123;initial catalog=RegisteredUsers;persist security info=True;user id=sa;password=passwordRemoved;application name=EntityFramework;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
        <add name="mywebsite_WWEMPPlain" connectionString="data source=tcp:123.123.123.123;initial catalog=mywebsite_WWEMP;persist security info=True;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;" />
        <add name="mywebsite_WWEMPEntities" connectionString="metadata=res://*/Models.Suppliers.csdl|res://*/Models.Suppliers.ssdl|res://*/Models.Suppliers.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tcp:123.123.123.123;initial catalog=mywebsite_WWEMP;persist security info=True;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        <add name="mywebsite_blogPlain" connectionString="data source=tcp:123.123.123.123;initial catalog=mywebsite_blog;persist security info=True;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;" />
        <add name="mywebsite_blogEntities" connectionString="metadata=res://*/Models.Blogs.csdl|res://*/Models.Blogs.ssdl|res://*/Models.Blogs.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tcp:123.123.123.123;initial catalog=mywebsite_blog;user id=sa;password=passwordRemoved;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
      <appSettings>
        <add key="webpages:Version" value="2.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="PreserveLoginUrl" value="true" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
        <add key="ServerPrefix" value="https://s3BucketRemoved.s3.amazonaws.com" />
        <add key="SupplierServerPrefix" value="http://removed.cloudimg.io/s/width/226/http://s3BucketRemoved.s3.amazonaws.com" />
        <add key="SupplierServerPressReleasePrefix" value="http://removed.cloudimg.io/s/crop/700x100/http://s3BucketRemoved.s3.amazonaws.com" />
        <add key="BlogAuthorPrefix" value="http://s3BucketRemoved.s3.amazonaws.com" />
        <add key="BlogHomeUrlPrefix" value="https://removed.cloudimg.io/s/crop/300x200/https://s3BucketRemoved.s3.amazonaws.com" />
        <add key="RegisterUrl" value="https://subs.mywebsite.co.uk/register?" />
        <add key="RetrievePwdUrl" value="https://subs.mywebsite.co.uk/forgottenpassword?" />
        <add key="MainUrl" value="http://localhost:64874" />
        <add key="ReturnUrl" value="http://localhost:64874/" />
        <add key="UpdateUserInfoUrl" value="https://subs.mywebsite.co.uk/edituserdetails?partyid=" />
        <add key="AccessHash" value="removed" />
        <add key="AccessToken" value="removed" />
        <add key="APIUrl" value="https://www.anapisite.com/" />
        <add key="LoadCount" value="15" />
        <add key="TwitterConsumerKey" value="removed" />
        <add key="TwitterConsumerSecret" value="removed" />
        <add key="TwitterToken" value="removed-removed" />
        <add key="TwitterTokenSecret" value="removed" />
        <add key="TwitterIDS" value="removed" />
        <add key="enableSimpleMembership" value="false" />
        <add key="autoFormsAuthentication" value="false" />
        <add key="DES_KEY" value="mywebsite" />
        <add key="roundtableFolder" value="C:\inetpub\folder\Content\folder\" />
        <add key="LuceneIndexFolder" value="c:\ProgramData\folder\" />
        <add key="staticImagesPath" value="../images" />
        <add key="TitleLength" value="100" />
        <add key="IntroLength" value="100" />
        <add key="DigitalIssuesWWTMagazine" value="c:\inetpub\wwwroot\folder\afile.xml" />
        <add key="DigitalIssuesWETNews" value="c:\inetpub\wwwroot\folder\afile.xml" />
        <add key="RegistrationGoal" value="http://localhost:64874/Register?Url=" />
        <!-- Banners Configuration-->
        <add key="LeaderBanner" value="1011" />
        <add key="MPUBanner" value="1012" />
      </appSettings>
      <system.web>

        <caching>
          <outputCacheSettings>
            <outputCacheProfiles>
              <add name="Cache" duration="0" varyByParam="none" />
            </outputCacheProfiles>
          </outputCacheSettings>
        </caching>
        <customErrors mode="Off" defaultRedirect="/Error">
          <error redirect="/Error/NotFound" statusCode="404" />
          <error redirect="/Error/InternalServerError" statusCode="500" />
        </customErrors>
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </assemblies>
        </compilation>
        <authentication mode="Forms">
          <forms loginUrl="~/Account/SignIn" timeout="2880" />
        </authentication>
        <httpRuntime requestValidationMode="2.0" />
        <pages validateRequest="false" />
        <membership defaultProvider="CustomMembershipProvider">
          <providers>
            <clear />
            <add name="CustomMembershipProvider" type="mywebsite.CustomMembershipProvider" connectionStringName="CustomMembershipPlain" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
          </providers>
        </membership>
      </system.web>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <!--optimization- starts-->
        <modules runAllManagedModulesForAllRequests="true">
          <add name="HttpHeadersCleanup " type="mywebsite.HttpHeadersCleanup, mywebsite" />
        </modules>
        <!--optimization- ends-->
        <handlers>
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
          <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
          <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
          <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
          <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
        <!--optimization- starts-->
        <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
          <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
          <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="image/*" enabled="true" />
            <add mimeType="application/x-pointplus" enabled="true" />
            <add mimeType="text/css" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="text/javascript" enabled="true" />
            <add mimeType="*/*" enabled="false" />
          </dynamicTypes>
          <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="image/*" enabled="true" />
            <add mimeType="application/x-pointplus" enabled="true" />
            <add mimeType="text/css" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="text/javascript" enabled="true" />
            <add mimeType="*/*" enabled="false" />
          </staticTypes>
        </httpCompression>
        <urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
        <staticContent>
          <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" cacheControlCustom="Public" />
        </staticContent>
        <httpProtocol>
          <customHeaders>
            <remove name="X-AspNet-Version" />
            <remove name="X-AspNetMvc-Version" />
            <remove name="Server" />
            <remove name="X-Powered-By" />
            <remove name="ETag" />
            <!--<clear/><add name="ETag" value=""/>-->
          </customHeaders>
        </httpProtocol>
        <!--optimization- ends-->
      </system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
          </dependentAssembly>
          <!--<dependentAssembly>
            <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.2.13.0" newVersion="2.2.13.0" />
          </dependentAssembly>-->
          <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.2.13.0" newVersion="2.2.13.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>
      <system.net>
        <mailSettings>
          <!--<smtp from="mywebsite@mywebsite.net" deliveryMethod="Network">
            <network host="smtp.sendgrid.net" password="0hPl3as3N0tAga1n" userName="mywebsitedotnet" port="587" />
          </smtp>-->
          <smtp from="email@mywebsite.com" deliveryMethod="Network">
            <network host="smtp.sendgrid.net" password="passwordRemoved" userName="mywebsite" port="587" />
          </smtp>
        </mailSettings>
      </system.net>
    </configuration>
Ralpharama
  • 441
  • 4
  • 20
  • Chrome caches redirects for very long. Perhaps the redirect was there once. https://stackoverflow.com/questions/16154672/how-long-does-chrome-remember-a-301-redirect – CodeCaster Dec 14 '17 at 10:42
  • Do you have solution configuration set to "Debug" or "Relase"? Can you show us web.config and web.debug.config? (Be carefull don't post any sensitive data like connection strings or passwords) And did you try to use different browser like IE? – garret Dec 14 '17 at 10:43
  • I cleared the Cache using Chrome Dev Tools/Application/Clear site data. No joy. – Ralpharama Dec 14 '17 at 10:44
  • 1
    It's set to 'debug' at the moment. I'll see if I can prep a web.config file to post here – Ralpharama Dec 14 '17 at 10:44
  • Edited to add redacted web.config, thanks! – Ralpharama Dec 14 '17 at 10:53
  • @Ralpharama do you have any tranformations in web.debug.config? – garret Dec 14 '17 at 10:59
  • Have you searched for www.mywebsite.com in the csproj file? and verified you're not using 'Release' (for example) build configuration which may be applying a transform? – Fermin Dec 14 '17 at 10:59
  • What is in the Start Action section of the Web tab in the project properties? – Crowcoder Dec 14 '17 at 11:41
  • @Fermin yes, searched and it doesn't exist. Definitely debug not release. – Ralpharama Dec 14 '17 at 12:14
  • @garret no transformations in web.config.debug I'm afraid – Ralpharama Dec 14 '17 at 12:14
  • @Crowcoder start action section completely blank. Project URL says http://localhost:64874/ – Ralpharama Dec 14 '17 at 12:16
  • @garret I just tried this with Firefox and it works! It loads the localhost version in debug mode. But when I switch back to Chrome it's on www redirect again! Now, I like Firefox but I would really like to get back to Chrome! – Ralpharama Dec 14 '17 at 13:03
  • @Ralpharama maybe this will help? https://superuser.com/questions/304589/how-can-i-make-chrome-stop-caching-redirects – garret Dec 14 '17 at 13:16

1 Answers1

0

It looks like chrome cashed redirect. You shuld clear cashe, you can try
cashe killer to do it automaticly

Or you can do it manualy
Bast answer for this question

garret
  • 1,134
  • 8
  • 16
  • I've tried all the solutions on those pages, re: cache. Tried Empty Cache and Hard Reload, and then, I cleared my entire cache of everything including my entire history and passwords and the problems persists! – Ralpharama Dec 14 '17 at 13:50
  • 1
    I awarded the answer to you @garret as the solution was, eventually, hidden away on that page in one of the suggestions: In chrome://net-internals and at the far right open the drop-down and choose "Clear Cache". Specifically though, you have to do this whist you are running the redirected page after compiling the .NET project, then type the localhost:9999 address. Then open this tab and clear the cache then - I tried this before just generally from Chrome and it did nothing! – Ralpharama Feb 01 '18 at 07:49