Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. login

login

Scheduled Pinned Locked Moved ASP.NET
questiondatabasetutorial
16 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M minhpc_bk

    Hi there, As Matthias pointed out that you may need to set up the Forms Authentication in your ASP.NET application to protect the restricted pages, the user will be directed to the login page when he tries to access those resources. And the originally requested url is added to the query string, once the user is authenticated, you can get that url in the query string with the key ReturnURL.

    X Offline
    X Offline
    xiaowenjie
    wrote on last edited by
    #7

    i did this in login.aspx..but cant seems to direct me to the requested page.. am i doing it right? if (status == 0) { string url = Request.QueryString["ReturnUrl"]; FormsAuthentication.RedirectFromLoginPage(txtUserID.Value.Trim(), true); Response.Redirect(url); } else { lbl.Text = "Invalid UserID or Password!"; } :confused:

    M 1 Reply Last reply
    0
    • X xiaowenjie

      i did this in login.aspx..but cant seems to direct me to the requested page.. am i doing it right? if (status == 0) { string url = Request.QueryString["ReturnUrl"]; FormsAuthentication.RedirectFromLoginPage(txtUserID.Value.Trim(), true); Response.Redirect(url); } else { lbl.Text = "Invalid UserID or Password!"; } :confused:

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #8

      You can use either the RedirectFromLoginPage method or the Redirect method to direct thr authenticated user to the originally requested page. Also, if you set up the Forms Authentication mode properly, then you will see the requested url added to the query string when the user is directed to the login page. http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetHT03.asp[^] http://www.codeproject.com/aspnet/formsroleauth.asp[^]

      X 1 Reply Last reply
      0
      • M minhpc_bk

        You can use either the RedirectFromLoginPage method or the Redirect method to direct thr authenticated user to the originally requested page. Also, if you set up the Forms Authentication mode properly, then you will see the requested url added to the query string when the user is directed to the login page. http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetHT03.asp[^] http://www.codeproject.com/aspnet/formsroleauth.asp[^]

        X Offline
        X Offline
        xiaowenjie
        wrote on last edited by
        #9

        i did my web.config as shown but still cant get it to work.. 1) <configuration> <system.web> <compilation defaultLanguage="c#" debug="true"/> <authentication mode="Forms"> <forms name="LoginForm" loginUrl="login.aspx" protection="All" timeout="60" slidingExpiration="true" path="/" /> </authentication> <machineKey validationKey="AutoGenerate" decryptionKey="AutoGenerate" validation="SHA1"/> </system.web> <location path="Temp"> <system.web> <authorization> <allow roles="Admin" /> <deny users="*" /> </authorization> </system.web> </location> </configuration> 2) do i need to create application name in Application Settings under the directory tab for the folder (Temp) where i place my order.aspx and customerinfo.aspx in IIS properties? 3)do i need to place the login page into the Temp folder too?

        M 1 Reply Last reply
        0
        • X xiaowenjie

          i did my web.config as shown but still cant get it to work.. 1) <configuration> <system.web> <compilation defaultLanguage="c#" debug="true"/> <authentication mode="Forms"> <forms name="LoginForm" loginUrl="login.aspx" protection="All" timeout="60" slidingExpiration="true" path="/" /> </authentication> <machineKey validationKey="AutoGenerate" decryptionKey="AutoGenerate" validation="SHA1"/> </system.web> <location path="Temp"> <system.web> <authorization> <allow roles="Admin" /> <deny users="*" /> </authorization> </system.web> </location> </configuration> 2) do i need to create application name in Application Settings under the directory tab for the folder (Temp) where i place my order.aspx and customerinfo.aspx in IIS properties? 3)do i need to place the login page into the Temp folder too?

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #10

          1. What do you mean by cannot get it to work? You cannot get the requedted URL or the authenticated user is always redirected to the login page? If so, can you run it in debug mode to see if you can get the url. 2. You don't need to create an Application for the temp folder, otherwise this folder is considered as a new application. 3. No, the login page should be accessible to all users.

          X 1 Reply Last reply
          0
          • M minhpc_bk

            1. What do you mean by cannot get it to work? You cannot get the requedted URL or the authenticated user is always redirected to the login page? If so, can you run it in debug mode to see if you can get the url. 2. You don't need to create an Application for the temp folder, otherwise this folder is considered as a new application. 3. No, the login page should be accessible to all users.

            X Offline
            X Offline
            xiaowenjie
            wrote on last edited by
            #11

            oh it keeps redirecting me to login page..im able to get the requested URL

            M 1 Reply Last reply
            0
            • X xiaowenjie

              oh it keeps redirecting me to login page..im able to get the requested URL

              M Offline
              M Offline
              minhpc_bk
              wrote on last edited by
              #12

              Do you have any code to set the role of the user? If no, you now can take a look at Heath's article to see how to do that because at the moment all the users are not allowed to access the Temp folder except those belong to the Admin group(role).

              X 2 Replies Last reply
              0
              • M minhpc_bk

                Do you have any code to set the role of the user? If no, you now can take a look at Heath's article to see how to do that because at the moment all the users are not allowed to access the Temp folder except those belong to the Admin group(role).

                X Offline
                X Offline
                xiaowenjie
                wrote on last edited by
                #13

                hey THANKS!!!!!!!!!!!!!!!! with your help im able to do it..anw i found another website which oso explain about it. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secmod/html/secmod18.asp

                1 Reply Last reply
                0
                • M minhpc_bk

                  Do you have any code to set the role of the user? If no, you now can take a look at Heath's article to see how to do that because at the moment all the users are not allowed to access the Temp folder except those belong to the Admin group(role).

                  X Offline
                  X Offline
                  xiaowenjie
                  wrote on last edited by
                  #14

                  hey sorry im back!!:-D yea i've got this problem. remember about the login n the web config thingy, i just test my program n this time the web browser says im not autorized to view tt page.. im not sure why but yester it was working..i didnt touch anything. the error was http 403 .. however if i click onto the back button till the index page and click the link to customerinfo.aspx, im able to go link to it..

                  M 1 Reply Last reply
                  0
                  • X xiaowenjie

                    hey sorry im back!!:-D yea i've got this problem. remember about the login n the web config thingy, i just test my program n this time the web browser says im not autorized to view tt page.. im not sure why but yester it was working..i didnt touch anything. the error was http 403 .. however if i click onto the back button till the index page and click the link to customerinfo.aspx, im able to go link to it..

                    M Offline
                    M Offline
                    minhpc_bk
                    wrote on last edited by
                    #15

                    Hi there, Can you post the full error message as there are a number of different http 403.x errors? Can you also take look at the ASP.NET Trace[^] to see if it can help?

                    X 1 Reply Last reply
                    0
                    • M minhpc_bk

                      Hi there, Can you post the full error message as there are a number of different http 403.x errors? Can you also take look at the ASP.NET Trace[^] to see if it can help?

                      X Offline
                      X Offline
                      xiaowenjie
                      wrote on last edited by
                      #16

                      Very sorry for the late reply, have been away. ok here is the error: You might not have permission to view this directory or page using the credentials you supplied. HTTP Error 403 - Forbidden :~ Chris

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups