Reputation: 263
I need to redesign a site front-end to make it responsive, the site is based on C# and ASPX. I am familiar with working PHP local development environment by using WAMP so for this case I installed visualstudio web express because of its IIS server features for testing local development.
The client sent the folder from its ftp for me to work on so I have everything ready but the problem which I am facing is that when I try to right-click on the website folder from the solution explorer to view in the browser the localhost is redirecting to the actual live site which is running on the server instead of taking me to the localhost with local files so that I can have a view of my modification and changes.
I am unable to figuring out the problem may be there is something I need to change or replace in the webconfig file. I am working in asp environment for the first time your help and guidance in this regard will be very appreciated.
Many thanks.
Upvotes: 3
Views: 7010
Reputation:
PROBLEM
I was facing this problem because I wrote this rule inside webconfig file.
<rules>
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.abc\.com$" negate="true" />
</conditions>
<action type="Redirect" url="www.abc.com/{R:1}" />
</rule>
</rules>
And because of this when I debug the solution the localhost is replaced with www.abc.com
SOLUTION
Just remove this rule if written
WHY USE RULE
These rules are used when you want to customize the url ,you can read further about Url Rewrite here
Upvotes: 1
Reputation: 1
For me it was because the web.config had a rewrite rule added in it for SSL purpose. However, once I removed it, it still kept me redirecting to the live site. I wasted couple of hours searching the code without anything making sense. And then it turned out that the cache was the issue as the browser was still doing the redirection. So, I cleared the cache and it was solved.
Upvotes: 0
Reputation: 1
Redirecting to the live site from visual studio or localhost can be caused by a faulty url rewrite rule in the site web config. Even if the rule is deleted, the browser may cache the rule if it is a permanent redirect, and therefore clearing the browser cache and fixing the faulty rule can be a viable solution.
See article https://theludditedeveloper.wordpress.com/2016/01/06/iis-url-rewrite-gotcha-2/
Upvotes: 0
Reputation: 53
I had this same problem just now as well as two or three times before and haven't pinned down a clear cut resolution, though I've tried removing redirects, checking the Global.asax, commenting out default document files in the Web.config, etc. I'm mainly working in Chrome on Windows 7, and after I cleared Chrome's cache localhost started working for me again. I don't know if the answer is as simple as that or if the solution comes from some combination of things. All I know is nothing else seemed to work, then clearing the browser cache did.
Upvotes: 5