Passing Custom User Object To WCF?

Mar 23, 2011

I've implemented a custom ASP.net membership provider to deal with forms authentication. The custom provider uses a custom User object for authentication and authorization. I was wondering If I can pass this object to each WCF call without adding it to the parameters list?

View 2 Replies


Similar Messages:

Passing Custom Object As Parameter To A Webmethod Of Web Service?

May 11, 2010

I have a custom class declared as follows (in vb.net)

<Serializable()> _ Public
Class NumInfo Public n As String
Public f As Integer Public fc As
char() Public t As Integer

[Code]....

What am I doing wrong? For the record I tried replacing char() with string to see if it was the array causing problems but that didn't help either. I'm fairly new to web services. I tried replacing the custom object parameter with a primitive parameter just to check how things worked and it rendered a page with an input field and invoke button.

View 1 Replies

Security :: Passing The User.identity Object To Shared Code?

Dec 13, 2010

I have a shared module in an asp.net web app which gets various information about a group or user. Since the Iuser account on the web does not have enough rights to query the AD, I need to supply an appropriate userid and passcode for the directoryentry in the shared code. Since my credentials so the have the appropriate rights to query the AD I like to impersonate myself(user.identity). This works fine for a webpage, but I can't pass the user.identity object to shared code. I get an error. Is there a way to pass the user.identity object to a shared function in another module?

View 1 Replies

Executing C# Code From Front End - Create A User Object By Passing Guid?

Nov 16, 2010

I have something like this

[code]....

it works fine, but I need to create a user object by passing Guid like this

MembershipUser user = Membership.GetUser(new Guid(userId));

what may be the cause. it woks fine from C# code behind.

View 1 Replies

Forms Data Controls :: Passing A Whole Object Through To The User Control Inside A Repeater?

Apr 16, 2010

I have a user control inside a repeater. I am binding a collection of objects to the repeater.

My user control has a public property to retrieve the object (setobject)

How do i pass each object through to the user control and not just the object property value? What is the syntax to do this?

[code]....

View 1 Replies

Custom Server Controls :: Passing Reportparameter Array To Web User Control?

Jan 20, 2010

I have a user control that contains a reportviewer control.And I want to send an array of reportparameter to my user control.But I can't figure out how to do.I'm getting "Object reference not set to an instance of an object. ".My param_reportParam variable is null in usercontrol.My user control's parameter is like that ;

[Browsable(false)]public ReportParameter[] param_reportParam{ get { return _param_reportParam; } set { _param_reportParam = value; }}private ReportParameter[] _param_reportParam;

And a simple page that uses user control to show server reports is like that ;

ReportParameter[] parameters = new ReportParameter[4];//parameter number can be different parameters[0] = new ReportParameter("imza", imzalayacaklar); parameters[1] = new ReportParameter("Sayi_Son_Eki", "984"); parameters[2] = new ReportParameter("PersonelTip", "2"); parameters[3] = new ReportParameter("parafli", "1"); wuc_rapor_genel1.param_reportParam = parameters;//this is my usercontrol

View 3 Replies

How To Add Some Custom Instance Properties To User Object

Nov 29, 2010

I'd like to add some custom instance properties to an ASP.Net User object. for example, I'd like to log every user's login and have something like: User.LoginTimes or calculate the User Profile's Completion percentage and be able to access it like: User.ProfileInfoPercentage, etc.

Now What I'd like to know is what would be the best approach to do this?

Forget about user instances? (e.g. define a database table with userid and ProfilePercentage info and retrieve data from profile like: DB.GetProfilePercentage(Context.Current.User.UserID) )
Override the ASP.Net User class and add my own functionalities.
Use Extension methods for the user class.

View 1 Replies

Forms Data Controls :: Using GridView With A User Control And Passing Object Into Control?

Jan 8, 2010

I would like to use the gridview paging feature and have built a gridview with a user control. The data source has lots of columns, so to make it easier I want to return a LIST<MyObject> and just pass <Myobject> into the user control rather than all the data elements. Not sure how I access the object of the data source to bind to the control. Assume it would be during ondatarowbound.

Also, my guess is there is a better way to do this than gridview. I'd take either solution that allows me to have easy paging and pass the complete object into the user control

View 7 Replies

Master Pages - Where's The Best Place To Store Custom "User" Object For The Duration Of Session

Jul 6, 2010

I have an ASP.NET application that needs to remember some info about a user (and what company they are from) across pages, within a session. I imagine this is a requirement of just about any ASP.NET application of a certain size. I've used a few different approaches over the years. In the past, I've passed around an id in querystring parameters like so: [URL] and then instantiated the object on each page (from the database). Another common way of doing it is storing my objects in session variables:

Session["User"] = currentUser; // store at login
User currentUser = (User)Session["User"]; // retrieve on some other page

which saves a trip to the DB, but I worry about memory used if the User object is complex and the site has many concurrent users. I have recently inherited an application that uses public properties on the master page, like this:

Master.theUser = currentUser; // store at login
User currentUser = Master.theUser; // retrieve on some other page

This saves the cast, and looks more readable to me I think, but I don't know if it's better or worse performance-wise. It also has some logic in the getter where if the private value is null, it tries to get it from the Session variable, though I'm not sure if that's never used (or used every get!?) or what. My latest idea is to use my page class. I have a custom page class derived from the standard System.Web.UI.Page base class. It includes objects like CurrentUser as public properties. This seems to work OK. I like it even better. But I really don't know what's going on under the covers. Can anyone give an opinion on which approach is better and why?

Update: I've done some checking use trace.axd and Trace.Write and it looks like neither the masterpage version nor the custom page class version "remember" the values between pages. The "get" methods have a line of code that checks if the User property is null, and if so, reads it from the session variable. This happens when a page accesses the property (Master.User or the derived class's this.User) for the first time on a given page, then subsequent requests can get the value (without going to the session variable). So thus far the best solution looks something like this:

public class MyPage : System.Web.UI.Page
{
private User user;
public User User
{
get
{
if (user == null)
{
user = (User)HttpContext.Current.Session["CurrentUser"]; //check if session[CurrentUser] is null here and log them out if so?
}
return user;
}
set
{
user = value;
HttpContext.Current.Session["CurrentUser"] = value;
}
}
}

Then on any webpage.aspx.cs, you can do something like this: UsernameTextBox.Text = User.FullName;

View 2 Replies

C# - How To Convert Json Object To Custom Class Object In Web Service

Aug 30, 2010

I've scenario where I want to insert data into database without post back. there are around 12 to 13 fields which i need to insert. I'm passing DTO from the client side which is actually Json object. Now the problem which i'm facing is how to convert that Json object which i got in webservice to the "class" (in my case class name is User) object.

[Code]....

In the above case AddNewUser method takes the object of User class. But i'm getting casting error. So how do I convert Json object to the "User" class object?

View 3 Replies

C# - Web Service Method Returns Response Object Instead Of Custom Object?

Sep 29, 2010

I have the following code:

[WebMethod]
[SoapHeader("_webServiceAuth")]
public User GetUser(string username){
try
{
this._validationMethods.Validate(_webServiceAuth);
User user = new User(username);
[code]...

View 1 Replies

How To Bind Form Collection Back To Custom Model Object That Uses 2 Custom Objects

Mar 23, 2010

What I'm trying to do is rather basic, but I might have my facts mixed up. I have a details page that has a custom class as it's Model. The custom class uses 2 custom objects with yet another custom object a property of one of the 2. The details page outputs a fair amount of information, but allows the user to post a comment. When the user clicks the post button, the page gets posted to a Details action that looks something like this:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Details(VideoDetailModel vidAndComment) { ....}
[Code]....

The only fields on the form that is posted are CommentText and VideoId. Here is what the VideoDetailModel looks like.

public class VideoDetailModel
{
public VideoDetailModel()
{
[Code]....
I suppose if I added more form fields for the properties I need, they would get posted, but I only need 1 form entry field for the CommentText. If I could get the same Model objects value that were sent to the page to post with the page, it looks like the solution is rather simple. I think using the RenderPartial in the middle of a form is problematic somehow to how the form gets written in html. I can't really put my finger on why things went bonkers, but if I do my RenderPartials before my form and then begin my form with the text entry field and the hidden VideoId, the default ModelBinder works just fine. I was beginning the form, writing the hidden VideoId, rendering several partial views, create my CommentText field, and then closed the form out. The CommentText field would get bound just fine. The hidden VideoId would not. Maybe I missed a rule somewhere about using RenderPartial.

For completeness, the partial view I was rendering took a Comment object and just wrote out it's CommentText data. Several of these objects would exist for a single Video object. All of this data was in a custom type and passed into the View (the main view) as it's Model. This partial view did not have a form and did not have any data entry fields.

View 2 Replies

State Management :: Adding A Custom Object In Custom Principal?

Dec 27, 2010

I have Create a Custom Principal and a Custom Identiy for my Web Application and upon forms authentication

1 Create a profile of type object

2 Assign it to the Principal profile

3 assign the principal to the Http.Current.User (this now has the complete profile information )

As i understand upon redirection the principal is recreated and i loose the information i had stored in the profile.

I there a way to persist the profile information ?

I though can achieve persisting some information using FormsAuthenticationTicket in userData but that wouldent solve my purpose ..

View 7 Replies

C# - Dispose Of Custom Object From Within Custom Membership Provider?

Apr 16, 2010

I have created my custom MembershipProvider. I have used an instance of the class DBConnect within this provider to handle database functions. Please look at the code below:

public class SGIMembershipProvider : MembershipProvider
{
#region "[ Property Variables ]"
private int newPasswordLength = 8;
private string connectionString;
private string applicationName;
private bool enablePasswordReset;
private bool enablePasswordRetrieval;
private bool requiresQuestionAndAnswer;
private bool requiresUniqueEmail;
private int maxInvalidPasswordAttempts;
private int passwordAttemptWindow;
private MembershipPasswordFormat passwordFormat;
private int minRequiredNonAlphanumericCharacters;
private int minRequiredPasswordLength;
private string passwordStrengthRegularExpression;
private MachineKeySection machineKey;
**private DBConnect dbConn;**
#endregion
.......
public override bool ChangePassword(string username, string oldPassword, string newPassword)
{
if (!ValidateUser(username, oldPassword))
return false;
ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, newPassword, true);
OnValidatingPassword(args);
if (args.Cancel)
{
if (args.FailureInformation != null)
{
throw args.FailureInformation;
}
else
{
throw new Exception("Change password canceled due to new password validation failure.");
}
}
SqlParameter[] p = new SqlParameter[3];
p[0] = new SqlParameter("@applicationName", applicationName);
p[1] = new SqlParameter("@username", username);
p[2] = new SqlParameter("@password", EncodePassword(newPassword));
bool retval = **dbConn.ExecuteSP("User_ChangePassword", p);**
return retval;
} //ChangePassword
public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
}
......
ConnectionStringSettings ConnectionStringSettings = ConfigurationManager.ConnectionStrings[config["connectionStringName"]];
if ((ConnectionStringSettings == null) || (ConnectionStringSettings.ConnectionString.Trim() == String.Empty))
{
throw new ProviderException("Connection string cannot be blank.");
}
connectionString = ConnectionStringSettings.ConnectionString;
**dbConn = new DBConnect(connectionString);
dbConn.ConnectToDB();**
......
} //Initialize
......
} // SGIMembershipProvider

I have instantiated dbConn object within Initialize() event. My problem is that how could i dispose off this object when object of SGIMembershipProvider is disposed off. I know the GC will do this all for me, but I need to explicitly dispose off that object. Even I tried to override Finalize() but there is no such overridable method. I have also tried to create destructor for SGIMembershipProvider.

View 2 Replies

How To Convert JSON Object To Custom C# Object

Feb 11, 2010

Is there an easy way to populate my C# Object with the JSON object passed via AJAX?

//This is the JSON Object passed to C# WEBMETHOD from the page using JSON.stringify
{"user":{"name":"asdf","teamname":"b","email":"c","players":["1","2"]}}
//C# WebMetod That receives the JSON Object
[WebMethod]
public static void SaveTeam(Object user)
{
}
//C# Class that represents the object structure of JSON Object passed in to the WebMethod
public class User
{
public string name { get; set; }
public string teamname { get; set; }
public string email { get; set; }
public Array players { get; set; }
}

View 4 Replies

MVC :: Passing Entire Object Rather Than Just ID?

Feb 22, 2010

I am working on a project where I have a form to create a new user. In that form we have a dropdown list that is populated from another table called ElectricCompanies. The Users table and ElectricCompanies tables are related (each User can only have one electric company, but electric companies can have multiple users). I am having trouble getting the Electric Company object to pass into the Users table. The Users table wants it to be passed as a object of the table ElectricCompanies, but right now it only passes the ID.

This is the code from the UserController under the Edit that I used to populate the ElectricCompany dropdown list:

Dim eleccomp = (From p
In _DB.ElectricCompanySet Select p)
ViewData("ElecComp") = New SelectList(eleccomp,
"ID", "Name")

Is there a way to pass an entire object rather than just the ID?

View 2 Replies

MVC :: Passing Object Through Pages?

Apr 7, 2010

My problem is to save or pass a table object and use it in other page/controller.

I want to pass the object through pages to save just in the last STEP.

My controller:

[Code]....

I need to save the "d" object to use(save to database) just in other page/controller.

View 8 Replies

Passing Variables Through Non HTML Object

Mar 11, 2010

I have a search page which generates a GridView of results based on the search terms entered by the user. One of the columns in GridView is called a DOI (Document Object Itentifier). This DOI is used to find academic papers through [URL] when a user enters a DOI string. What I would like to do is redirect the user to the relevant webpage when they have selected the DOI in the GridView, however, the url for this page is always different. In the page, I have formatted the form tag like so: [URL] and in my GridView, I have formatted the row that I wish to have hyperlinked like so:

<asp:ButtonField DataTextField="DOI" HeaderText="DOI" CommandName="d"/>

Then, in my C# codebehind, I have the following event which aims to redirect the user to the required page, based on the tag they have selected:

switch (e.CommandName)
{
case "d":
searchResult.Attributes.Add("onchange", "window.open [URL]
break;
}

I don't think this code above makes any difference though as the form tag is already specifying the redirected url, nor do I think this task can be done with a html <table> object, as it only accepts static data, rather than a result set generated from a database, which is what I'm doing. I have also looked at the following post as a guide to this type of problem but, taking account of what it said didn't allow me to solve this problem completely. GridView with DDL and selected value

View 1 Replies

MVC :: Return RedirectToAction() Passing Object?

Apr 9, 2010

I have the following ActionResult() method:

[Code]....

The method is called once the <form> is submitted. If the validation is good, it moves on to create a new user Once the new user is created, I want to redirect the user to a "ThankYou" page passing along the newly created user (object). The TempData["User"] trick seems to work like a charm! Then inside my ThankYou ActionResult() I do the following:

[Code]....

The problem I have is once the user has been redirected to the "ThankYou" page. If he decides to refresh (F5) his browser, the value in the TempData is lost.

What are my possibilities to overcome this issue?

Instead of passing an entire object to my "ThankYou" page, I initially thought of passing the ID of the newly created user and re-query my database to get the object.

The only problem is that the ID will be seen in the QueryString allowing the user to simply change the ID value and try to find other users...

Is my only other alternative to simply place the user object inside a Session? Is that my only other option?

View 6 Replies

Page.User.Identity.IsAuthenticated Returns Object Reference Not Set To Instance Of Object?

Dec 23, 2010

this works fine on my local site but as soon as i upload the site to my live server i get stem.NullReferenceException: Object reference not set to an instance of an object

on the first line of this:

if (!Page.User.Identity.IsAuthenticated)
{
pnlSignIn.Visible = true;
pnlSignOut.Visible = false;
}

View 1 Replies

C# - Web User Control With Content Inside It / Object Reference Not Set To An Instance Of An Object

Aug 11, 2010

Usage :

[code]...

The problem is it gives me following error :

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 21: {
Line 22: base.OnInit(e);
Line 23: _ContentTemplate.InstantiateIn(BodyControlSpace);
Line 24: }
Line 25:

View 3 Replies

Security :: Trying To Get The GUID After The User Has Logged In/Object Reference Not Set To An Instance Of An Object

Oct 20, 2010

What is wrong with this code? The error is Object reference not set to an instance of an object.

I have the below code in my class, then on the login page i need the GUID so i can perform a lookup in one of our custom tables. But then the error above pops up before the page even loads at the line Guid guid = (Guid)userInfo.ProviderUserKey;

[Code]....

View 4 Replies

AJAX :: Passing DataSet Object As ResponseText?

Nov 24, 2010

Working with asynchronous postback. onclick of "OK" button i m fetching data from DB and it is in dataset without page-refresh.

DataSet ds = new DataSet();
ds = SearchResult.GetDataTable("dbo.spGetEmployeeDetails", thisConnection, searchItem);

1. How can i pass this dataset object to javascript as responseText?
2. In javascript i have to create table(create rows depending on number of nodes in dataset) and display responseText in aspx.

View 1 Replies

Passing Business Object Structure To UserControl?

Feb 17, 2010

How do it do this. I have this at the moment

[Code]....

[Code]....

This takes a large INT and returns 4 strings from the BO structure HotelFacilities

If I set the private from string to AccommodationBO.HotelFacilities it is fine

If I set the public from string to AccommodationBO.HotelFacilities it moans because the Set section of the private property is wrong. But the set would be an INt.

All I actually want to do, is populate the BO Structure and passit to the user control using a property in the user control code behind. Is this possible ??

Dim jim As New GetAccommodationPricesBLL

View 1 Replies

Passing A List Of Object From A View To The Controller In Mvc?

Mar 26, 2010

ss a list of objects as a paramter in an actionlinkAt the moment when I try to do this the list is always empty by the time it reaches the controller!

<%= Url.Action("ActionName", new { list = Model.ListOfObjects}) %>
public ActionResult ActionName(List<Object> list)
{
//Do stuff
}

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved