Security :: One Dimensional Array With AddUsersToRoles Method
Oct 15, 2010
I've created an Excel spreadsheet for my users to upload into my web application to bulk import memberships and roles into the application. There are up to 4 different roles which users can be members of so I'm using AddUsersToRoles to add the user to one or more roles in one line of code like this:
r.AddUsersToRoles(usernames, CreateListOfRoles(Role1, Role2, Role3, Role4))
As this line of code expects a one-dimensional array of roles, I have created a function to take in the roles from my spreadsheet, add them into a one-dimensional array, and return that to the AddUsersToRoles method. The CreateListOfRoles function looks like this:
[Code]....
The error that I'm getting though is "System.InvalidCastException: At least one element in the source array could not be cast down to the destination array type." I've stepped through the Function in debug mode and all the values look correct and there are the correct number of items in the array so I don't understand what's going wrong.
View 3 Replies
Similar Messages:
Feb 19, 2010
First I am sorry if I am creating a thread in the wrong category as I am not sure which is the best suitable place for this question: I want to create a user defined data structure, which will be a 2 dimensional array such that each individual square of this 2-dimensional array will also store the score and the grades. ( Iam using VB.NET) More details: for example: There is an 2 dimensional array with 3 columns and 2 rows, I want to fill each of the (0,0);(0,1);(0,2) with their own score (Integer type) and grades (String Type). And this is same for the rest of the squares i.e. (1,0);(1,1);(1,2) and (2,0);(2,1);(2,2) After creating such custom data structure: "CustomArray", I should be able to create the instance of this custom data structure (which will be a class) and code something like this:
Dim objCustomArray as CustomArray
objCustomArray = New CustomArray
for i as Integer =0 to 3
objCustomArray(0,i).SetScore(1)
objCustomArray(0,i).SetGrade("Good")
Next
-------
for i as Integer =0 to 3
Dim myVal as Integer = objCustomArray(0,i).GetScore()
Dim myGrade as String = objCustomArray(0,i).gettGrade()
Next
-----
View 4 Replies
Jun 22, 2010
I have a 2 dimensional array, I want to convert it to an Excel document using C#.
View 2 Replies
Jul 23, 2010
Can we use a 2 dimensional array to bind it in our form? In my model I have this:
public class EmailDetails {
public string[] emailTo { get; set; }
public string[,] emailFieldValues { get; set; } }
So in my form to bind the emailTo is simple and this one works:
<input type="text" id="Text1" title=" " name="emailTo" maxlength="100" />
<input type="text" id="Text1" title=" " name="emailTo" maxlength="100" />
I need a 2 dimensional array so that I can match the value with something,
like this:<input type="text" id="Text1" title=" " name="EmailDetails["@name",valueofinput] maxlength="100" />
View 4 Replies
Apr 6, 2010
I have this array: string[,] productData = new string[5,7];
I bind it to a repeater and a call a method like: <img src="<%# getPhoto1WithReplace(Container.ItemIndex) %>"
Which is defined like:
public String getPhoto1WithReplace(Object itemIndex) {
int intItemIndex = Int32.Parse(itemIndex.ToString());
if (productData[intItemIndex, 3] != null) return this.ResolveUrl(productData[intItemIndex, 3].ToString());
else return String.Empty; }
I do not understand why it calls getPhoto1WithReplace with itemIndex as 5. My array has 5 indexes: 0,1,2,3,4, so How Container.ItemIndex can be 5?
View 2 Replies
Apr 20, 2010
I am getting an error when trying to serialize an object products.
Product product = new Product();
product.Name = "Apple";
product.Expiry = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[3,2] { {"Small","40"}, {"Medium","44"}, {"Large","50"} };
string json = JsonConvert.SerializeObject(product);//this line is throwing an error
Array was not a one-dimensional array. Is there any way to serialize a two dimensional array with Newtonsoft.json.
View 2 Replies
Jul 6, 2010
I have this data:
5-16-2010, 5
5-16-2010, 3
5-16-2010, 2
5-16-2010, 4
5-15-2010, 2
5-15-2010, 5
5-15-2010, 1
5-14-2010, 3
5-14-2010, 5
I want to group by the date, these values are now in a dataset. What comes up to my mind is an array list with the following: The master array would have each date listed on the dataset above, within each row of this array I would have the list of numbers for that specific date. How do I do that in VB.NET?
View 2 Replies
Oct 8, 2010
How do you store multi-dimensional array to viewstate? Here's what I did:
public bool[,,] regsettings = new bool[7,5,4];
bool[,,] regsettings = (bool[,,])ViewState["regsettings"]; // this line works!
regsettings[i,j,tab] = (bool)ViewState["regsettings"]; // this line no working?! The error is: Object reference not set to an instance of an object. The letters i,j, tab are just variables in the loop. They are there. I also tried: (bool[,,,]) as a cast and it is a no-go either.?
View 1 Replies
Nov 13, 2010
I know I can use arrayName.length to find out how many items in total in the array there are, but how can I gracefully find out how many items are in a specific dimension? I know I could probably do it in a for each loop, but it would look a little messy, does anyone know of a simple way that I may have overlooked?
View 3 Replies
Mar 11, 2010
My original code was in classic vb. and could use redim array to resize them. I was porting the code to c# now and lately i have run into an issue to resize a 2 dimensional array. The thing here is I have a 2 dimensional array whose 2nd dimension needs to be increased dynamically as needed to accommodate the data. For say
String[,] ary1=new String[2,10];
I'm doing some operation in a loop and filling in the data in ary1. And if the loop still continues, on reaching the ary1 upper bound i need to increase the size further to accommodate 10 more rows. I tried couple of ways to copy it to a bigger array and assign it back to the current array. but somehow dint work.
View 1 Replies
Sep 10, 2010
i want to pass multidementional array as parameter, below the code i worked, is it right
class ASRateContract
{
public string[,] standardrate = new string[3,2];
public string[,] storagerate = new string[3,3];
public void setstandardrate( string [3,2]name )
{
standardrate = name;
}
public string setstoragerate()
{
return "";
}
public string getstandardrate()
{
return standardrate;
}
View 6 Replies
Mar 14, 2011
I am trying to return some data as json from an action method.
I have an employee object that looks like this:
public class Employee
{
public int EmployeeID {get; set;}
public string FirstName {get; set;}
public string LastName {get; set;}
//Other irrelevant properties
}
Then I have a view model as follows
public Class EmployeeViewModel
{
public Employee Supervisor{get; set;}
public List<EmployeeViewModel> Employees
}
I need to return a json object that looks exactly like this:
{id: 1, name: John, children: [
{id: 1, name: Joe, children: []},
{id: 1, name: Rob, children: []}
]}
For now I only need to go to the second level as above, returning and supervisor and their staff members beneath them.
How would I go about returning this in my action method(I have the viewModel object hydrated already I just need to return it as json). My problem so far has been that the children property does not get populated.
View 1 Replies
Jun 16, 2010
I am looping through a dataset and I would like to have the following in this array list
name, from, to, price
john, 40, 50, 39.99
mike, 20, 50, 49.99
etc.
Once I do that, or if it is possible to do it using the dataset that will work with me. But I want to do...
If john's price between from and to...
So in my code I wanted to make it easy for me and instead of memorizing the row #, I would just do.. arraylist.row("john").item("from")
View 6 Replies
Aug 19, 2010
I need to know what would be the best choice of array to use given the following specifications. This array's size will be predermined upon the loading of the appication. All I want to do is be able to add values to this array and replace preexisting array items with new values without the array changing size. Someone suggested that I use a Dictionary Array Object? I would appreciate any suggestions.
View 3 Replies
Feb 28, 2011
I'm trying to use the Membership.CreateUser method without passing a security question and answer. I set them to string.empty, but no go. I have my provider set to not require a question in my web.config. What am I doing wrong?
[Code]....
View 2 Replies
Mar 16, 2010
reading on the web ive found the code below; i wonder if an encrypted string using this block generates an unique result or if different encrypted sources can result in the same crypted array:
private static TripleDES CreateDES(string password)
{
MD5 md5 = new MD5CryptoServiceProvider();
TripleDES des = new TripleDESCryptoServiceProvider();
des.Key = md5.ComputeHash(Encoding.Unicode.GetBytes(password));
des.IV = new byte[des.BlockSize / 8];
return des;
}
View 3 Replies
May 12, 2010
Iam getting an array of list from database to client side(javascript array). Now my aim to place those values in a div one by one and that div should attach to the textbox similar to Autocomplete extender.
View 4 Replies
Mar 17, 2010
How can I do this?I want to be able to manually specify the location that I want the user to be redirected to using this method....?
FormsAuthentication.RedirectFromLoginPage
View 4 Replies
Aug 12, 2010
how to pass a C# ASP.NET array to a Javascript array? Sample code will also be nice.
Let's say for simplicity that in my aspx.cs file I declare:
int [] numbers = new int[5];
now I want to pass "numbers" to the client side and use the data in the array within javascript. How would I do this?
View 4 Replies
Jul 12, 2010
I have a WCF service and there are four methods in it. I want to allow 2 methods to client 1 and the other 2 methods to client 2.
View 2 Replies
Aug 2, 2010
I want to know how can I protect my password in login & register pages because I am not using .net's Login or CreateUserWizard controls.I want an encryption method for this process e.g. when storing password in the database form the register page and when comparing the password with stored password in database to varify a user in login page.
View 3 Replies
Dec 3, 2010
I have few queries regarding installation of SSL certificate.How much time will it take in installing the SSL certificate and getting the IIS https enabled?
Is there any risk involved with the installation of SSL certificate that might bring down the applications hosted on the IIS.Will the application hosted on that IIS continue working with HTTP?(I don't want each application to be https enabled.
View 4 Replies
Jan 8, 2010
Whenever I try to use the Website Administration Tool i get an error messege stating:
error invoking ad&minister website.
Details: The method or operation is not implemented.
How can I fix this?
View 4 Replies
Jul 15, 2010
I am using a standard implementation of the membership provider. I however, need to compare a supplied password (from a textbox) with a saved encrypted password. This is for a new security policy at work.
[Code]....
View 6 Replies
Dec 18, 2010
I'm currently developing a website using .net MVC 3 and I'm on the authentication layer...Here is the scenario: user is logged with the "remember me" option checked : a user Session is created on the server as well as the authentication cookie on the client side.The Session timeout is set to 20 minutes.After 25 minutes of inactivity the user goes back onto the website and Session, now expired, does not exist anymore but the authentication cookie still exists
View 1 Replies