From time to time I encounter issues linking to page in Visual Studio when working with ASP.NET application.
I create links to pages but they always redirect to the default one (Default.aspx)<ul><li>I trying various thing like deleting and recreate</li> <li>Rename the page</li> <li>Even If the page does not exist it still redirects to the defaults page.</li> </ul>
Login.aspx page is the same folder as
ForgotPassword.aspx I create links like this
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="ForgotPassword.aspx"> Forgot your password ? </asp:HyperLink>
<a href="ForgotPassword.aspx">Forgot your password ?<a>
I am at loss to understand why such basic stuff would fail to work... How can I solve this issue? Could this be a bug?
EDIT: The Url in the browser looks like this:
<authentication mode="Forms"> <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> </authentication>Answer1:
I solve this by adding the following to my web.config file:
<location path="ForgotPassword.aspx"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location>Answer2:
What happens when you compile your web site? If Visual Studio cannot find your ForgotPassword.aspx page, you should get a Warning in your Error List that says "File 'ForgotPassword.aspx' was not found." Note that this will appear in the Error List tab, not the Output tab.
Assuming you are not getting this warning...hmm. The only thing that pops into my head is maybe you have a default behavior specified? If it cannot find the page specified in the link, you should get a 404. If your website is hosted in IIS, you can specify behaviors when you get error messages, like 404s. Maybe IIS is doing something where it redirects a 404 to go to a Default.aspx page?
Also, I just noticed you started off with "from time to time". So that means this is an inconsistent error? The links sometimes work, but sometimes they don't? If that's the case, something is seriously wrong and it may be some sort of bug in Visual Studio, a plug-in, or something else. Reinstall when all else fails!Answer3:
What does your Authorization node look like in your Web.config? My guess is that the path to your Forgot Password page is requiring an authenticated user.