Random String Generator Creates Same String On Multiple Calls
May 2, 2010
I've build a random string generator but I'm having a problem whereby if I call the function multiple times say in a Page_Load method, the function returns the same string twice.here's the code
Public Class CustomStrings
''' <summary>'
''' Generates a Random String'
''' </summary>'
''' <param name="n">number of characters the method should generate</param>'
''' <param name="UseSpecial">should the method include special characters? IE: # ,$, !, etc.</param>'
''' <param name="SpecialOnly">should the method include only the special characters and excludes alpha numeric</param>'
''' <returns>a random string n characters long</returns>'
Public Function GenerateRandom(ByVal n As Integer, Optional ByVal UseSpecial As Boolean = True, Optional ByVal SpecialOnly As Boolean = False) As String.............
View 4 Replies
Similar Messages:
Dec 15, 2010
I create a table as picture below :
when I insert any character to column Name then A new string random will auto insert into column Random (picture below) I had used Trigger but It was error !
I want to column Random use to code :
DECLARE @myid uniqueidentifier
SET @myid = NEWID()
insert into table_1 values(@myid, substring(CONVERT(varchar(255), @myid), 1, 5))
but It must auto like column Number (column Number is Identity)
View 1 Replies
Jul 21, 2010
For some reason the following JSON string creates the correct number of records in the custom objects array, but does NOT populate the objects in the array with and values.
[code]....
View 2 Replies
Mar 11, 2011
I want to create a random password generator in my ASP.NET C# web application.
I have created that but it is applicable only for the integer format. If I give any characters it shows the debugging error as "my input format is wrong".
But i want to enter both string and integer. For example my textbox field may be
[code]....
View 4 Replies
Aug 31, 2010
I am looking for some solution of the random user image.I created some image and calling it from database if user has no image.But i dont like it, it is quite ugly.Is it exists some random image generator, like here in stackoverflow the the user has no photo.
View 2 Replies
Oct 7, 2010
Random rand = new Random((int)DateTime.Now.Ticks);
int numIterations = 0;
numIterations = rand.Next(1, 50);
Response.Write(numIterations.ToString());
Response.Write(' ');
numIterations = rand.Next(1, 50);
Response.Write(numIterations.ToString());
Response.Write(' ');
numIterations = rand.Next(1, 100);
Response.Write(numIterations.ToString());
Response.Write(' ');
numIterations = rand.Next(50, 100);
Response.Write(numIterations.ToString());
[Code]....
This is what i have so far. first 2 number gives 1-50, then 1-100, then last two give 50-100
now i need to make the first 2 numbers give even or odd numbers. how can i do this?
View 4 Replies
Sep 20, 2010
I have an ASP.NET application that relies on the Random class to generate a pseudo-random string. It uses the following code (this is part of a larger piece of sample code provided by Google for apps SSO):
public static class SamlUtility
{
private static Random random = new Random();
private static char[] charMapping = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p' };
public static string CreateId()
{
byte[] bytes = new byte[20]; // 160 bits
[Code]...
This normally works very well, but from time to time it starts generating a string of 'a'. From what I can tell from debugging, Random simply stops returning random numbers and instead fills bytes with the same value over and over. I've patched this by using a GUID instead, but I'm curious what happened in the original code. I'm assuming some form of entropy exhaustion, but I can't find any reference in the docs. Also, each time this has happened, performing iisreset restored the correct behavior.
View 1 Replies
Mar 18, 2011
I have a table with three fileds userID, userName, userPassword.I have 100 rows in that table, now I want to update the userPassword column with new random generated string password.
View 1 Replies
Aug 18, 2015
While running a project in asp.net in local and live I am getting unwanted characters in th URL.. Given below the sample of the URL
Can I know whats the reason for this
localhost:3482/Emp/(S(j3llqowtu2ow0lwqvqk0g12t))/Details.aspx
localhost:3482/Emp/(S(j3llqowtu2ow0lwqvqk0g12t))/Details.aspx
View 1 Replies
Nov 8, 2010
I work on an ASP.Net 4 project that uses forms authentication.The majority of our users login without any trouble, however, something strange is happening with a small number of users and I think we've narrowed it done to the User Agent string.Most users when logged in will see a fairly standard looking URL, e.g. http://mywebsite.co.uk/Web/Pages/Default.aspx, the "web" folder is the root of the site.
Some users when logged in are producing URLs such as
http://mywebsite.co.uk/Web/(F(wjNTtmLFYK3PyAUD09idKtZcyRPlf3Mlc6_rJMMwd1r0EvxeL1ROKYoTbd6KQWJNJHebiCs8qN4laZAItib4ZmcfMy75KhGlBrMCjY-47phUNQiJ_Q0-E3ntvf8tscjxfD5A0lVXau-UxDvN6gTgW1TkwhA1))/Pages/Default.aspx. I can only assume the garbage characters are some sort of session identifier string.
These obscure, long URLs work fine for some pages, but a lot of pages (including our home page) use the LoadControl(path) method to dynamic load content, or have hyperlinks to static files on the server (e.g. PDFs). In these scenarios the users with the long URLs crash the application as obviously the files it's looking for don't exist because the paths have been obscured with garbage characters.
We can reproduce this error by using masking the User Agent in Firefox to emulate the Googlebot, and sometimes the iPhone. Is there a particular reason why some user agents will produce this behaviour? Can anyone shed any light at all on why the random string is being injected into every URL on our sites?
/Web/(F(wjNTtmLFYK3PyAUD09idKtZcyRPlf3Mlc6_rJMMwd1r0EvxeL1ROKYoTbd6KQWJNJHebiCs8qN4laZAItib4ZmcfMy75KhGlBrMCjY-47phUNQiJ_Q0-E3ntvf8tscjxfD5A0lVXau-UxDvN6gTgW1TkwhA1))/FDCrew/Airlines/DHL/HomeFooterPanel.ascx
View 5 Replies
Dec 1, 2010
How can I generate a 7-digit random number and special character string in a textbox on a button click event, in VB.Net?
View 2 Replies
May 10, 2010
I have a webservice (ASP.NET) deployed on a webfarm. A client application consumes it on daily basis. The problem is that some of its calls are duplicated (with difference of milliseconds). For example I have a function Foo(string a,string b). The client app calls this webmethod as Foo('test1','test2') once but my log shows that it is being called twice or sometimes 3 or 4 times randomly. Is this anything wrong with the webfarm or the code? Note that the webmethod has simple straighfarward insert and update statements.
View 1 Replies
Dec 24, 2010
I m facing some problem. i m not passing Dynamic string through query string..
I m using this code
string abc = "CPCB_" + TextBox1.Text + "_" + TextBox2.Text;
Response.Write("<script>window.open('xml.aspx?Flag=3&date='+abc,target='new');</script>");
View 2 Replies
Feb 24, 2011
i facing a problem to change the date format at gridview display.
below is my coding:
[code]....
View 2 Replies
Feb 13, 2010
on VWD 2005 this code works fine, but on 2008 it says I haven't created an instance of the object. I want to convert the object connString (a connection string) into a string.
'This acceses the virtual directory web.config file for connection strings
'We have to convert the object to a connection string
Dim rootWebConfig As System.Configuration.Configuration
rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/VirtualDirec")
Dim connString
As System.Configuration.ConnectionStringSettings
connString = rootWebConfig.ConnectionStrings.ConnectionStrings("ConnectString1")
Dim strConnString
As
String = connString.ToString().......
View 5 Replies
Jul 7, 2010
I'm concatenating a string in codebehind to use in a sql select statement.
in aspx
<asp:Label ID="LabelHidden" runat="server" Visible="False"></asp:Label>
SelectCommand="SELECT * FROM [Data] WHERE [ActivityName] IN (@ActivityName) AND ([ID] = @ID)"
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList_Employees" Name="ID"
PropertyName="SelectedValue" Type="Int32" />
<asp:ControlParameter ControlID="LabelHidden" Name="ActivityName"
Type="String" />
</SelectParameters>
in codebehind
foreach (ListItem li in ListBox_Activities.Items)
{
if (li.Selected)
{
queryBuilder += li + "', ";
}
queryBuilder = queryBuilder.Substring(0, queryBuilder.Length - 1);
LabelHidden.Text = queryBuilder;
When i run the code it comes up blank. I did a query trace and it seems to be running as
exec sp_executesql N'SELECT * FROM [Data] WHERE [ActivityName] IN (@ActivityName) AND ([ID] = @ID)',N'@EmployeeID int,@ActivityName nvarchar(50)',@EmployeeID=4,@ActivityName=N'Production Technical Support'', Tools Development'','
with exta "'s
How can i format the queryBuilder string correctly in my code?
View 3 Replies
Jul 20, 2012
//Read string contents using stream reader and convert html to parsed conent var parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(contents), null);
//Get each array values from parsed elements and add to the PDF document foreach (var htmlElement in parsedHtmlElements) pdfDoc.Add(htmlElement as IElement);
//Close your PDF pdfDoc.Close(); Response.ContentType = "application/pdf";
//Set default file Name as current datetime Response.AddHeader("content-disposition",
[Code] ....
Error: Input string was not in a correct format. Contents in html file giving error ...
View 1 Replies
May 7, 2015
Suppose i am having 25 character length string and I want to bind only first 15 character of that string into the label control.
<a href="[URL]" >"<span class="name" style="text-align: left; font-family: Arial; color: #0094DA; font-size: 14pt">
<%#Eval("Name").ToString().Length >= 30 ? Eval("Name").ToString().Substring(0, 30) : Eval("Name").ToString()%></span></a>
View 1 Replies
Jan 26, 2011
At debug time I would like to see what are the keys in my InitParams collection - I can't seem to be able to list them.
EDIT:As Jon suggests below, this might be a bug within the Silverlight debugger. To reproduce, just create a new Silverlight Application within Visual Studio 2010 and just edit code
{
public partial class MainPage : UserControl
{ [code]...
View 2 Replies
Jul 28, 2010
I have project in development where string operations like "Hi " + variable + ", welcome to Project" are used at many places (given example is very minor one).
One of the requirement is to convert it to string.format style.
It is very long and tedious job, where I would not like to break earlier working code due to any human error might happen while converting it.
I would like to if any Macro or VS command which I can create to handle it. Just like we mark block of code and do Extract function in Re-factor options.
View 1 Replies
Feb 15, 2011
I want to split a string that taking both string and integer values like (Cmp_12). I want to use them in Separately.
View 4 Replies
Jan 28, 2011
I am fetching some data from Db and displaying it in a textarea using jquery in the following way.$('#textareatest').val('<% =teststring %>').It is possible that the string 'teststring' can contain XHTML line breaks(<br/>).whenever the string contains <br/> I am getting the 'unterminated string literal' error.I saw a number of posts considering '' as line breaks and suggesting to escape it.I tried to escape the <br/> similarly,but it didn't work.
View 4 Replies
Feb 26, 2011
public class Package
{
public Package()
{
name = "";
type = new List<Dictionary<string, string>>();
}
public string name { get; set; }
public List<Dictionary<string, string>> type { get; set; }
}
[code]...
View 2 Replies
Aug 9, 2010
I have an sql resultset which is retrieved after searching through the database using the LIKE keyword. I want to display the result on a page but without showing the whole text. Just the paragraph where the result was found. Maybe even put that particular word in bold. how best I can implement this?
View 1 Replies
Feb 23, 2011
i have created a encrypted string to match with a target string to pass it along with client URL for authentication. it doesn't match. here is an algorithm used to create a encrypted string.
text = "astringtobeencrypted";
string strglobalkey = "mytestglobalkey";
string hexivkey = "testing12345";
ebCryptLib.eb_c_Cipher ci = new ebCryptLib.eb_c_Cipher();
string strhex1 = ConvertStringToHex(strglobalkey);
string strhex2 = ConvertStringToHex(hexivkey);
byte[] bytes = (byte[])ci.EncryptStringRaw(EB_CRYPT_CIPHER_ALGORITHM.EB_CRYPT_CIPHER_ALGORITHM_DES3_ECB,
strhex1, strhex2, text);
return Convert.ToBase64String(bytes);
the above alogithm returns a string which doesn't match with our targetted string provided by the client.
what should i do to match with the targetted string? The client had generated the encrypted string using PHP.
View 3 Replies