Click here to Skip to main content
Sign Up to vote bad
good
Hello Friends,
 
i sue formauthertication in my application and i use login button in index page for control panel for admin user. but my most page are public.
 
when i run my application
 
http://localhost:65300/site/Public/frmLogin.aspx?ReturnUrl=%2fsite%2fPublic%2fIndex.aspx
 
<authentication mode="Forms">
     <forms loginUrl="~/Public/frmLogin.aspx" name="Egyan"   />
   </authentication>
   <authorization>
     <deny users="?"/>
   </authorization>
 
its directly goes to login page with return url instead of index page.
 

please help me.
Posted 8 Jan '13 - 21:54

Comments
Aman.A - 9 Jan '13 - 9:43
did you set your start page in Visual Studio? right click on the page in your Visual Studio solution and click on "set as start page" and see if that solves your problem.

1 solution

Kindly use the following code. It may help.
 
Here "loginUrl" is the redirect url that will work only for those pages which need authentication. Onthe other hand the "defaultUrl" will allow the user to visit the normal pages. Here in my code the .aspx pages inside the admin folder of the root directory will be asked to login, if anyone requests any page in admin section.
 
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Forms">
      <forms timeout="30" loginUrl="login.aspx" defaultUrl="default.aspx" />
    </authentication>
  </system.web>
  <location path="admin">
    <system.web>
      <authorization>
        <deny users="?" />
      </authorization>
    </system.web>
  </location>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 8,356
1 OriginalGriff 6,571
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid