Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to generate some passwords (password generator), but I want to avoid characters that can be confused with each other (for example: Chair2bok). How can I do that?
Why don't you just use a character set that you DO want to use rather than those to avoid?
A standard set of 64 characters
!#%+23456789:=?#ABCDEFGHJKLMNPRS
TUVWXYZabcdefghijkmnopqrstuvwxyz
A larger set of 88 characters
!"#$%&'()*+,-./23456789:;<=>?#ABCDEFGHJKLMNO
PRSTUVWXYZ[\]^_abcdefghijkmnopqrstuvwxyz{|}~
Source: Characters to avoid in automatically generated passwords
I blogged about how to generate a strong password for SQL Server HERE.
It uses strings that you can remove the characters you don't want. I've already removed some like 1, I, 0, and O.
private static string CHARS_LCASE = "abcdefgijkmnopqrstwxyz";
private static string CHARS_UCASE = "ABCDEFGHJKLMNPQRSTWXYZ";
private static string CHARS_NUMERIC = "23456789";
private static string CHARS_SPECIAL = "*-+_%/";
private static string CHARS_ALL = CHARS_LCASE + CHARS_UCASE
+ CHARS_NUMERIC + CHARS_SPECIAL;
To generate passwords of various complexity, you can use the services. For example, GetPas (online password generator).
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am developing a website using ASP.NET MVC, how can I get the current location (Country, city, district, lat-lng geolocation) of each visitor browses my website depending on IP address?
It's possible to get location by using IP address of visitor. Use web-service provided by ipinfodb.com :
string url = string.Format("https://api.ipinfodb.com/v3/ip-city/?key={0}&ip={1}&format=json", APIKey, ipAddress);
using (WebClient client = new WebClient())
{
string json = client.DownloadString(url);
Location location = new JavaScriptSerializer().Deserialize<Location>(json);
return location;
}
There are several services out there that can do this. Try, for example, this one: http://geoip.nekudo.com.
An example: http://geoip.nekudo.com/api/8.8.8.8
Look for "ip geolocation rest api".
There are many geo-localization service you can use. For example, I do this way.
Put this tag inside your main .html page:
<script type="text/javascript" src="https://l2.io/ip.js?var=userIp"></script>
Than you will find a global variable called userIp with the calling ip address.
Than you can use any geolocation tool to get all the information you need.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to export some data from datatable to .csv file. But the data are not coming to the .csv file its coming as a blank file
A StreamWriter should be closed to have the data written to its internal buffer flushed to the file.
So you really need to enclose the creation of the StreamWriter inside a using statement.
The using statement manages the closing of the file and releases the system resource (the file handle). All this happens automatically when you reach the closing brace at the end of the using block ALSO in case of exceptions.
using(StreamWriter sw = new StreamWriter("D:\\report.csv"))
{
... all the code that read the datatable and write in the stream....
} // here you get: sw.Flush(); sw.Close(); sw.Dispose();
It seems also that you append a comma at the end of each line also for the last column.
Inside the loop the line
if(i != dt.Columns.Count)
is never false because you exit from the loop when the variable i reaches the dt.Columns.Count value. Change it to
if(i < dt.Columns.Count-1)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a search field form that I use to insert filterexpression on a aspx page.
I would like to force user to insert a string similar to a sql like condition, so it can be:
Start or not with %, so %?
Write letters, numbers, whitespace, underscore but not a special character like %, so [A-Za-z0-9-_+()\s]+
Ends or not with %, so %?$
My reg expression is %?[A-Za-z0-9-_+()\s]+%?$ but it doesn't work because I can write %test%test% that is not a sql like condition.
I have to force writing %test or test% or test or %test% but not %test%test% because the search goes in an error page.
How to do this?
Thanks
You were very close, just missing the start of string operator ^. Without that, you allow a match on your regex on any part of the input, which is why you were able to match things like %test%test%. The expression as you had it would just match starting at the second %.
using System.Text.RegularExpressions;
using System;
public class Program{
public static void Main(string[] args) {
Regex rgx = new Regex(#"^%?[A-Za-z0-9-_+()\s]+%?$");
Console.WriteLine(rgx.IsMatch("%test%")); //True
Console.WriteLine(rgx.IsMatch("%test %test%")); //False
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I Need to import excel file into Sql server, i have tried by using Fileupload but the fileuploader acccepting all file types, is there any chance to restrict only selected types when we click on browse?
An alternative would be using AjaxFileUploader:
In Markup:
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" OnClientUploadComplete="uploadComplete" OnClientUploadError="uploadError"
onuploadcomplete="AjaxFileUpload1_UploadComplete" AllowedFileTypes="xls,xlsx"
MaximumNumberOfFiles="1"/>
For more info : AjaxFileUpload
Extract file extension from filename and check.
string Extension = Path.GetExtension(fileUploadControlId.PostedFile.FileName);
use regex to validate file types
var regex = new Regex(#".*\.xlsx?$");
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am implementing URL REWRITE (IIS 7) in a client's website.
but I have a problem with the sql statement.
before I had this:
select * from 360 where titulo='"&request("titulo")&"'"
and it was ok.
an example of titulo was "Fiexpo Latinoamérica"
my old url was portfolio.asp?titulo=Fiexpo Latinoamérica
but now my new url is /portfolio/fiexpo-latinoamerica
I use ASP replace to remove the spaces and change them with an "-" among others simbols.
so now, my sql statement does not works... because there is no titulo in the database with that name.
how do I do?
I could easyle replace the - with an space, ok but I have "tildes" á é í ó ú
what do I do?????
How is that new URL generated? You should save the new URL (slug) for every item in the database so you can use that to generate the links and to search it when somebody is requesting the page.