C# - How To Extend The User.Identity Property
Jul 30, 2010
I'm not talking about asp.net membership.
For each logged user I want to cache some properties like status or the number of friend requests, from the db.
I can create custom class which would do it but I thought it will be better to extend the existing User.Identity property. Something like this:
Label1.Text = User.Identity.Status;
View 2 Replies
Similar Messages:
Jul 8, 2010
is possible to create another property like 'userid' as i can access like
HttpContext.Current.User.Identity.userid ? if yes , how? (actualy last year i did something like this but i have forgotten
View 1 Replies
Mar 16, 2011
I'm trying to extend the requirefieldvalidator to take a new property and validate regularexpressions also. I know I can use the RegularExpression control but then i need 2 controls so i want to eliminate it so i only have to use two controls. There are also other features i want to make which include me extending it. My problem is i don't know what to override - i tried the Validate() but i get "cannot override inherited member 'System.Web.UI.WebControls.BaseValidator.Validate()' because it is not marked virtual, abstract, or override" and i understand the EvaluateIsValid() is for validating the control not what is in the control.
[code].....
View 2 Replies
Feb 2, 2011
In IIS Manager center pane, there is an icon titled "Authentication" as follows: Clicking the icon, we get 3 items as follows: Right clicking the Anonymous Authentication and select edit, we have: Question: which one should I use? What is the difference?
View 3 Replies
Aug 12, 2010
i have a WebUserControls with 2 file : UCTMyControl.ASCX and UCTMyControl.ASCX.CS
In file UCTMyControl.ASCX.CS i have 1 virtual method Example: Virtual void Hello();
and now in Page example : MyPage.aspx and MyPage.aspx.cs
i want override method Hello() above in Web User Controls
how can i do ?
View 2 Replies
Feb 25, 2011
I am busy writing my own custom attribute for my action method called MyAuthorizeAttribute, I am still busy writing the code, here is my partial code:
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class MyAuthorizeAttribute : AuthorizeAttribute
{
public new Role Roles;
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
if (Roles != 0) // Did it this way to see what the value of Roles was
return;
// Here I am going to get a list of user roles
// I'm doing my own database calls
filterContext.Result = new HttpUnauthorizedResult();
}
}
Here is my Role enum:
public enum Role
{
Administrator = 1,
SuperAdministrator = 2
}
My action method:
[MyAuthorize(Roles = Role.Administrator|Role.SuperAdministrator)]
public ActionResult Create()
{
return View();
}
The reason why I did not use Roles = "Administrator,SuperAdministrator" was because the roles are hard-coded. I don't want to have a 100 places to change if the role name changes.
Given my method, when it gets to if (Roles != 0) then Roles total value is 3, how would I check to see if these 2 roles is in the list of user roles for a specific user?
Am I doing it correct here? If not how would I otherwise implement this? It doesn't have to be the way that I did it in.
View 2 Replies
Aug 31, 2010
I'm trying to create a user control class that extends Panel. Essentially, what I want to do is to have a panel that fires off an event whenever it's clicked upon.
So, I create something like this:
[Code]....
And then, in the ClickPanel.ascx.cs file:
[Code]....
I'm not exactly sure whether this would work as I haven't had the opportunity to test it yet.
The problem is that I can't have a class inherit from Panel. Creating a user control class requires that my class extend User Control - at least that's what the error messages have been saying up until now. The problem is that if I do extend it from the base class of UserControl then I lose all the functionality of the Panel itself and the entire thing is rendered pointless.
View 1 Replies
Dec 8, 2010
I have modal popup extender with two buttons called continue and cancel within it.I get this popup warning when session is going to expire.When I click cancel button it should logout me and when I click continue button it should extend my session for next 20 minutes. Both button gets trigered when I click them.Problem is that when I click continue button it should extend session for another 20 minutes and alert should disapper.That doesn't work.
[Code]....
View 2 Replies
Dec 23, 2010
I have implemented Forms authentication in an ASP.NET MVC 2 website
By using <%: Page.User.Identity.Name %> on the Site.Master page I can display the userid of the logged in user.
I would like to use this value and display other information about the user that is stored in a User table in a MsSQL database, like:
<%: GetFirstname(Page.User.Identity.Name) %>
View 2 Replies
Jan 30, 2011
get the below error. My application was working fine until I probably modified something, but don't know what.
Server Error in '/' Application.
Method is only supported if the user name parameter matches the user name in the current Windows Identity.
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.Configuration.Provider.ProviderException: Method is only supported if the user name parameter matches the user name in the current Windows Identity.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ProviderException: Method is only supported if the user name parameter matches the user name in the current Windows Identity.]
System.Web.Security.WindowsTokenRoleProvider.GetCurrentWindowsIdentityAndCheckName(String userName) +2195661
System.Web.Security.WindowsTokenRoleProvider.GetCurrentTokenAndCheckName(String userName) +36
System.Web.Security.WindowsTokenRoleProvider.GetRolesForUser(String username) +61
System.Web.Security.RolePrincipal.IsInRole(String role) +182....
View 1 Replies
Oct 27, 2010
i want to use dataset , or any thing ... to display Sum * where user= user.identity.name(not use gridvew, or formview) because i have more then 100 columns . i m newbie. realy , 1 month, it not solve, sometime , i want to give up
View 3 Replies
Mar 2, 2010
I have created a web services (WCF) and i have a webmethod that return a string that string is a HTTPCONTEXT.USER.IDENTITY.USER unfortunately it does not return any value.
View 9 Replies
Jun 28, 2011
In the IIS, it shows that the web app (i'm using) is using an application pool that uses NETWORK SERVICE account for identity. But when I debug/run my web app, User.Identity.Name shows that my windows user login instead. I checked my web.config file, and it does not have Impersonate enabled. In fact, I set it to false, and it still shows the same.
View 1 Replies
Mar 4, 2010
Is there a simple way to just retrieve the user's name, and not the Domain name, when using this function:
string quizTaker = Page.User.Identity.Name.ToString();
Right now it returns "DOMAIN_NAMEUserName"
I would like to just use isolate and use the user's name, without the Domain name.
View 2 Replies
Jun 9, 2010
i currently work on an asp.net mvc 2 project and noticed that inside an asp.net mvc view page i can get the user name authenticated via User.Identity.Name, but if i try to use the DsiplayFor method in order to display my model from a view user control, it just does not exist. Could i pass this parameter to my model using additional ViewData parameter that comes with DisplayFor html extension?
View 2 Replies
Jun 12, 2010
I need to create Unit Tests for an ASP.NET MVC 2.0 web site. The site uses Windows Authentication.I've been reading up on the necessity to mock the HTTP context for code that deals with the HttpContext. I feel like I'm starting to get a handle on the DI pattern as well. (Give the class an attribute of type IRepository and then pass in a Repository object when you instantiate the controller.)
What I don't understand, however, is the proper way to Mock the Windows Principal object available through User.Identity. Is this part of the HttpContext? have a link to an article that demonstrates this (or a recommendation for a book)?
View 2 Replies
Nov 15, 2010
I want to get the user specified in the app pool identity (which for us is a domain user). I want to get this info in Application_Start.
View 2 Replies
Oct 7, 2010
what is the use formsAuthentication.user.identity
is it one of the property of page
View 1 Replies
Jun 2, 2010
I use FormsAuthentication.RedirectFromLoginPage(userName.Trim(), false); to set the User.Identity.Name field that I reference later. When I execute this line, the User.Identity object does not update at all; it contains whatever it was previously set to. All the documentation I see online says this should update my User.Identity object with the correct name, but I don't see that happening.
I have the web config set up properly with the following lines:
<authentication mode="Forms">
<forms name="formsauth" loginUrl="Login.aspx" protection="All" timeout="60">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
View 1 Replies
Oct 20, 2010
am writing a web service in vb.net/asp.net 2, that needs user's name. It works fine when the url request is "www.mysite.com" but if any one has logged-in using "mysite.com" without a "www" and goes to the page that calls my web service, The HttpContext.Current.User.Identity.Name gives null. How can I resolve this problem?
View 2 Replies
Oct 5, 2010
For SqlDataSource I can configure the external source for the incoming paramater. For example it might be a QueryString, Session, Profile and so on. However I do not have an option to use User as a source.
I know that I could provide value for the parameter in Inserting,Selecting,Updating,Deleting events. But I do not think that this is an ellegant solution because I have some parameteres already definied in aspx file. I do not want to have parameters defined in two separate places. It makes mess.
So can I somehow define this parameter in .aspx file?
<SelectParameters>
<asp:QueryStringParameter DefaultValue="-1" Name="ID"
QueryStringField="ID" />
//User.Identity.Name goes here as a value for another parameter
</SelectParameters>
View 1 Replies
Mar 3, 2010
how do i add user.identity.name into db through sqldatasource in vb?
View 16 Replies
Oct 17, 2010
After setting the auth cookie using
FormsAuthentication.SetAuthCookie("myusername", False)
server.transfer("somepage.aspx") to open a web page.
Context.User.Identity.Name is found to be empty
But if I use
Response.Redirect("somepage.aspx")
Context.User.Identity.Name provides correct result.
I am aware of the differences between Response.Redirect and server.transfer. But exactly what is the reason behind this particular behaviour ?
View 1 Replies
Feb 14, 2011
I have an ASP.NET app that logs Audit reports using nHibernate's IPreUpdateListener. In order to set the current user in the Listener events, I was using System.Security.Principal.WindowsIdentity.GetCurrent(). This works fine when debugging on my machine, but when I move it to the staging server, I'm getting the ASP.NET process credentials, not the requesting user.
In the ASP.NET page, I can use Request.LogonUserIdentity (which works fine since I'm using integrated authentication), but how do I reference this user directly without having to pass it directly to my event? I don't want to have to pass this info through the pipeline because it really doesn't belong in the intermediate events/calls.
View 1 Replies
Jun 1, 2010
In the website we have several folders, some folders are accessible by anonymous users, others are accessible by members only, some by administrators or a both administrators and members can view this folder. Each folder contains some forms; these forms are based on the role as well. We'd like to add "user.identity" as to authenticate the user based on the user_id from table websit_ users.
However we are not sure , wither we need to specify each and every form, folder or this will be done automatically once authentication is applied. And where do we put the user.identity and what is the exact format of it. Do we include it in our Global.asax after the authentication part?! This is the code in global.asax:
[Code]....
View 1 Replies