FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Create Random Url's In Asp.Net





umeshtangnu
Hi
How Can i create random URL's in asp.net
i tried googling but all i can get is php code
umeshtangnu
Create a table in mySQL with the fields 'code' (varchar(xx) where 'xx' is the length of your secret code), 'filename' (varchar(yy) where 'yy' is the maximum length of a file's name), and 'expires' (DATETIME).


In the file that gives the link to the user:
Code:

     $sSecretCode = ... your 'random' number generating code ... ;
    $sFileName = ... filename to be accessed ... ;
    $iValidSecs = ... seconds that link should be valid ...

    if (mysql_query("INSERT INTO tblCodes SET code='$sSecretCode',
          filename='$sFileName',expires=(NOW() + $iValidSecs)")) {
      // Code was added to database
      $sLink = "http://yourdomainname.com/file.php?c=$sSecretCode&n=$sFileName";
      echo "The link to the file is: <A HREF=\"$sLink\">$sLink</A>";
    } else {
      // Code was not added
      echo "There was an error setting up your link.";
    }

    // Use this file access as a trigger to clean out tblCodes
    $rslt = mysql_query("DELETE FROM tblCodes WHERE expires<NOW()");


In the file 'file.php':
Code:

    // Use this file access as a trigger to clean out tblCodes
    $rslt = mysql_query("DELETE FROM tblCodes WHERE expires<NOW()");

    $sSQL = "SELECT * FROM tblCodes WHERE code='" . addslashes($c)
             . "' AND filename='" . addslashes($n) . "' AND expires>=NOW()";
    if ($rslt = mysql_query($sSQL)) {
       if (mysql_num_rows($rslt) > 0) {
          // valid code for file

          // DELETE CODE (allow only one access of the file)
          $rslt = mysql_query("DELETE FROM tblCodes WHERE code='" . addslashes($c)
                . "' AND filename='" . addslashes($n) . "'");

          // Take the user to the file:
          header("Location:  http://yourdomainname.com/filedir/" . addslashes($n));
       } else {
          echo "File is not accessible.";
       }
    } else {
       echo "Error attempting to access file.";
    }


This is only piece of code i could get
can some body translate it from php to .net
Related topics
I'd love ASP.NET support
Using TinyMCE with ASP.NET
Flash & ASP.NET
ASP.NET - Is this possible with frihost?
Web hosting com Asp.net
Suggest me a ASP.NET Spidering Book
Running ASP && ASP.NET -> APACHE
Asp.net 2.0 and ajax technology
asp.net 2.0
ASP.NET 2.0 supported?
Using Windows Media Player with Asp.NET
Does Grid view in ASP.net have ItemDataBound event
ASP.Net and OutLook
asp.net email form
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.