[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Hyperlink to webform not working... nothing happening when site is running on IIS

I have two hyperlinks. One is to a html page (works fine) the other is to a web form.

So, when I am debugging, both work fine and the page is displayed. However, when I publish it onto IIS and access it from another computer, the hyperlink to the web form does nothing (even though it works fine when debugging). Any ideas on this?

Thanks, Aiden
<asp:HyperLink ID="HyperLink8" runat="server" Font-Bold="True" Font-Size="X-Small"
            ForeColor="Orange" NavigateUrl="~/Using This Site.htm" Style="z-index: 106; left: 46px;
            position: absolute; top: 176px" Width="96px" TabIndex="5">Using this site
</asp:HyperLink>
 
<asp:HyperLink ID="hplForgotPassword" runat="server" Font-Bold="True" Font-Size="X-Small"
            ForeColor="Orange" NavigateUrl="~/Password.aspx" Style="z-index: 105; left: 46px;
            position: absolute; top: 208px" Width="113px" TabIndex="6">Forgot Password / Change Password?
</asp:HyperLink>

Open in new window

0
AidenA
Asked:
AidenA
  • 9
  • 8
1 Solution
 
GiftsonDJohnCommented:
Hi,

There is no problem in the code. It should work fine.
0
 
AidenAAuthor Commented:
yeah but it doesn't :)
0
 
GiftsonDJohnCommented:
When you put the mouse over the HyperLink, is the url displayed on the Status Bar correct? or It is not at all displaying as HyperLink
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AidenAAuthor Commented:
Hi,

Yes the url displayed is correct. When I click the link to my site the url is

http://myIPAddress/test1/login.aspx

then the link on my page is to the PasswordPage.aspx and when I click the link the url that is displayed by IE is http://myIPAddress/Test1/Login.aspx?ReturnUrl=%2ftest1%2fPasswordPage.aspx

and instead of seeing hte PasswordPage, I still see the Login page? It works fine in Visual studio debugger as I said? So I guess the fact that it is saying ReturnUrl means that it is returning to the login page?
0
 
GiftsonDJohnCommented:
Hi, This is because of the forms authentication enabled on your site. It will include all the files under your root to be redirected to the page Login.aspx. Only after successful authentication you will be able to visit all the other pages. But you can exclude PasswordPage.aspx from the authentication. You have to include
<configuration>
<location path="PasswordPage.aspx">
      <system.web>
         <authorization>
            <allow users="?"/>
         </authorization>
      </system.web>
   </location>
.
.
.
.
</configuration>
0
 
AidenAAuthor Commented:
didn't work... maybe i didn't put it in the right place?
<configuration>
 
  <location path="PasswordPage.aspx">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>
 
 
  <appSettings/>
	<connectionStrings/>
	<system.web>
		<!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
 
            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        -->
		<roleManager enabled="true"/>
		<customErrors defaultRedirect="~/Error.aspx"/>
		<compilation debug="true">
			<assemblies>
				<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
			</assemblies>
		</compilation>
		<pages>
			<namespaces>
				<clear/>
				<add namespace="System"/>
				<add namespace="System.Collections"/>
				<add namespace="System.Collections.Specialized"/>
				<add namespace="System.Configuration"/>
				<add namespace="System.Text"/>
				<add namespace="System.Text.RegularExpressions"/>
				<add namespace="System.Web"/>
				<add namespace="System.Web.Caching"/>
				<add namespace="System.Web.SessionState"/>
				<add namespace="System.Web.Security"/>
				<add namespace="System.Web.Profile"/>
				<add namespace="System.Web.UI"/>
				<add namespace="System.Web.UI.WebControls"/>
				<add namespace="System.Web.UI.WebControls.WebParts"/>
				<add namespace="System.Web.UI.HtmlControls"/>
			</namespaces>
		</pages>
		<!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
       
		<authentication mode="Windows"/>
		
    -->
		<authentication>
			<forms name="cookie" loginUrl="login_a.aspx" timeout="2">
				<credentials passwordFormat="Clear"/>
			</forms>
		</authentication>
		<authorization>
			<deny users="?"/>
			<allow users="*"/>
		</authorization>
		<!--
    
    The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
 
        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        
        
        -->
	</system.web>
</configuration>

Open in new window

0
 
AidenAAuthor Commented:
by the way, i always have to manually change the authentication to 'forms' in IIS... I think I had some errors in my code or something and when I change windows to forms it doesn't work properly something like that
0
 
GiftsonDJohnCommented:
Can you try this

<location path="PasswordPage.aspx">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

If it doesn't work

You can try this

<location path="PasswordPage.aspx">
    <system.web>
      <authorization>
        <allow users="?,*"/>
      </authorization>
    </system.web>
  </location>
0
 
AidenAAuthor Commented:
neither worked. you're right about the forms authentication though... if i sign in and then click the back button in the browser and click the link it works then
0
 
GiftsonDJohnCommented:
Similar question was asked in EE and the same method was applied.

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_21430620.html
0
 
GiftsonDJohnCommented:
Try moving the <location> tag to the bottom
0
 
AidenAAuthor Commented:
ok i put it at the bottom like so, and now i'm getting directed to my Error.aspx page, so there is some error in this structure now?
<configuration>
 
  <appSettings/>
  <connectionStrings/>
  <system.web>
    <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
 
            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        -->
    <roleManager enabled="true"/>
    <customErrors defaultRedirect="~/Error.aspx"/>
    <compilation debug="true">
      <assemblies>
        <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
    </compilation>
    <pages>
      <namespaces>
        <clear/>
        <add namespace="System"/>
        <add namespace="System.Collections"/>
        <add namespace="System.Collections.Specialized"/>
        <add namespace="System.Configuration"/>
        <add namespace="System.Text"/>
        <add namespace="System.Text.RegularExpressions"/>
        <add namespace="System.Web"/>
        <add namespace="System.Web.Caching"/>
        <add namespace="System.Web.SessionState"/>
        <add namespace="System.Web.Security"/>
        <add namespace="System.Web.Profile"/>
        <add namespace="System.Web.UI"/>
        <add namespace="System.Web.UI.WebControls"/>
        <add namespace="System.Web.UI.WebControls.WebParts"/>
        <add namespace="System.Web.UI.HtmlControls"/>
      </namespaces>
    </pages>
    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
       
		<authentication mode="Windows"/>
		
    -->
    <authentication>
      <forms name="cookie" loginUrl="login_a.aspx" timeout="2">
        <credentials passwordFormat="Clear"/>
      </forms>
    </authentication>
    <authorization>
      <deny users="?"/>
      <allow users="*"/>
    </authorization>
    <!--
    
    The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
 
        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        
        
        -->
  </system.web>
 
  <location path="PasswordPage.aspx">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
  
</configuration>

Open in new window

0
 
AidenAAuthor Commented:
actually that makes it clear i need to improve my custom error reporting... i'm just going to take a look at this and see what error is coming up
0
 
AidenAAuthor Commented:
ok this is getting weirder... if i remove the custom errors section the site does the same as before, if i now add the custom errors section (with global.aspx as above with location at the bottom) then I am taken to the error.aspx page?
0
 
GiftsonDJohnCommented:
I can't see any problem.

replace

<customErrors defaultRedirect="~/Error.aspx"/>

with

<customErrors mode="Off" />

The site will show the exact error message. You will be able to identify the issue.
0
 
AidenAAuthor Commented:
Ah, my mistake... I had a naming problem with the aspx page so i was acutally using the wrong name in the config file (a copy and pasting of my project issue).

The solution that is accepted works fine. Thanks for your help!

Aiden
0
 
GiftsonDJohnCommented:
Good work :-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 9
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now