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. How to pass username and password between sites?

How to pass username and password between sites?

Scheduled Pinned Locked Moved ASP.NET
helpquestiondatabasetutorial
5 Posts 4 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.
  • P Offline
    P Offline
    PunkIsNotDead
    wrote on last edited by
    #1

    Hi! I'm working in two sites! lets say that first is the public second the private one! in public site, we add a login form which redirects to the second site (in case the username and psw are correct). Now I want the user login in second site instead showing the login page (which are by default) My current problem is that sessions don't work between sites. And Query Strings are very unsecure in that way (any user writing the correct QS would login or psw would be seen in the url). How can I correct this little issue?? :confused:

    A A 2 Replies Last reply
    0
    • P PunkIsNotDead

      Hi! I'm working in two sites! lets say that first is the public second the private one! in public site, we add a login form which redirects to the second site (in case the username and psw are correct). Now I want the user login in second site instead showing the login page (which are by default) My current problem is that sessions don't work between sites. And Query Strings are very unsecure in that way (any user writing the correct QS would login or psw would be seen in the url). How can I correct this little issue?? :confused:

      A Offline
      A Offline
      Andreas X
      wrote on last edited by
      #2

      If you encrypt your data before puttning it into the query string, i think this is the best way. you can encrypt using the following method:

      public static string Encrypt(string originalString)
      {
          if (String.IsNullOrEmpty(originalString))
          {
              throw new ArgumentNullException("The string which needs to be encrypted can not be null.");
          }
      
          DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
          MemoryStream memoryStream = new MemoryStream();
          CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoProvider.CreateEncryptor(privateKey, privateKey), CryptoStreamMode.Write);
      
          StreamWriter writer = new StreamWriter(cryptoStream);
          writer.Write(originalString);
          writer.Flush();
          cryptoStream.FlushFinalBlock();
          writer.Flush();
      
          return Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
      }
      

      where privateKey is a byte[] of choice.

      private static byte[] privateKey = ASCIIEncoding.ASCII.GetBytes("#privateKey#!!#");

      or something like that.

      Andreas Johansson
      IT Professional at Office IT Partner i Norrbotten Sweden
      What we don't know. We learn.
      What you don't know. We teach

      P 1 Reply Last reply
      0
      • A Andreas X

        If you encrypt your data before puttning it into the query string, i think this is the best way. you can encrypt using the following method:

        public static string Encrypt(string originalString)
        {
            if (String.IsNullOrEmpty(originalString))
            {
                throw new ArgumentNullException("The string which needs to be encrypted can not be null.");
            }
        
            DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();
            MemoryStream memoryStream = new MemoryStream();
            CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoProvider.CreateEncryptor(privateKey, privateKey), CryptoStreamMode.Write);
        
            StreamWriter writer = new StreamWriter(cryptoStream);
            writer.Write(originalString);
            writer.Flush();
            cryptoStream.FlushFinalBlock();
            writer.Flush();
        
            return Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);
        }
        

        where privateKey is a byte[] of choice.

        private static byte[] privateKey = ASCIIEncoding.ASCII.GetBytes("#privateKey#!!#");

        or something like that.

        Andreas Johansson
        IT Professional at Office IT Partner i Norrbotten Sweden
        What we don't know. We learn.
        What you don't know. We teach

        P Offline
        P Offline
        PunkIsNotDead
        wrote on last edited by
        #3

        Hi! thanks for reply! Ok! that's a good alternative! I've read about it and it seems well! but I was wondering if there's a way to don't involve the url in the login process! Anyway it might be the best solution (if there isn't another better) Thanks Andreas X ;)

        R 1 Reply Last reply
        0
        • P PunkIsNotDead

          Hi! thanks for reply! Ok! that's a good alternative! I've read about it and it seems well! but I was wondering if there's a way to don't involve the url in the login process! Anyway it might be the best solution (if there isn't another better) Thanks Andreas X ;)

          R Offline
          R Offline
          raju melveetilpurayil
          wrote on last edited by
          #4

          http://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged.aspx[]

          Raju.M

          1 Reply Last reply
          0
          • P PunkIsNotDead

            Hi! I'm working in two sites! lets say that first is the public second the private one! in public site, we add a login form which redirects to the second site (in case the username and psw are correct). Now I want the user login in second site instead showing the login page (which are by default) My current problem is that sessions don't work between sites. And Query Strings are very unsecure in that way (any user writing the correct QS would login or psw would be seen in the url). How can I correct this little issue?? :confused:

            A Offline
            A Offline
            aashish saalvi
            wrote on last edited by
            #5

            Ap per my knowledge query string is the best option to pass values to other sites/web pages. Hope this helps.

            Hope this helps.

            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