Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid returnURL getting appended automatically in server?

Tags:

c#

asp.net

I am using Forms authentication in web.config and when I am redirecting my page to some specific pages, returnUrl gets appended automatically and system redirects to Login page. These specific pages should be opened irrespective of the fact that the user is Logged in or not.

This works fine when I debug it in Local machine but is giving such behaviors when I am deploying the build on Server.

Please help me as I am stuck badly on this.

like image 481
Gopesh Avatar asked Nov 25 '11 11:11

Gopesh


2 Answers

You can have specific pages excluded from Forms Authentication like so:

<configuration>
   <location path="Logon.aspx">
      <system.web>
         <authorization>
            <allow users="?"/>
         </authorization>
      </system.web>
   </location>
</configuration>

See http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx

like image 120
Muhammad Hasan Khan Avatar answered Sep 21 '22 09:09

Muhammad Hasan Khan


The configuration in web.config file(s) are applied in a hierarchical way. To apply authentication settings (either allow or deny) to more than one page you can use this fact by putting a web.config file with authentication settings in a folder of your website that contains the pages that you need to secure, or another in the folder containing the pages that you don't want to secure. The web.config will apply to all pages in that folder.

Check this MSDN article: ASP.NET Configuration File Hierarchy and Inheritance.

Differences in behavior between local machine and build server imply differences in the configuration. That's one possible explanation.

like image 21
Mzn Avatar answered Sep 23 '22 09:09

Mzn