MVC :: How To Retrieve User.Identity.Name From View User Control
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?
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.
I'm in the middle of moving a web application from IIS6 to IIS7. I've enabled "Windows Authentication" and added <deny users="?" /> to the authorization section of my web.config file. When the app was running on IIS6 my users where able to access the web app without logging in because their windows login was automatically recognized. This does not seem to be the case in II7. I can not get a value for "Current.User.Identity.Name" in my ASP.Net code.
have a web in which there are different areas i have a 1 admin which manage all things like news, Events, Notices, Logs, Forums, Publications etc.........i want assign user rights that select user view only Noticesselect user view only Logsselect user view only Newsetc....
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....
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
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.
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.
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?
I don't think I understand fully how ASP.NET does inheritance of controls.I have a user control, ucBase, which has an asp.net label in the ascx file. Code behind references the label and it works fine during run time if the control is not a parent for another user parent.
If I have another user control, ucChild, inheriting from ucBase, the label in ucBase's code is always null. ucChild has no controls in its ascx fileThe server controls (like the label) needs to be declared in the ascx file and not created programmatically.What needs to be done for ucBase to see its own controls when it's a parent user control?
When a user wants to view another user profile on user profile page this error will show up
ERROR
Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please 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 72: protected void OnDataBound(object sender, EventArgs e) Line 73: { Line 74: string userName = (FormView1follow.Row.Cells[0].FindControl("hfUserName") as HiddenField).Value; Line 75: string friendsUserName = (FormView1follow.Row.Cells[0].FindControl("hfFriendsUserName") as HiddenField).Value; Line 76: string followStatus = (FormView1follow.Row.Cells[0].FindControl("hfFollowStatus") as HiddenField).Value;
Is there a way to create templates in an MVC 2 View User Control much like the ability of a Web User Control? or should I just use a Web User Control? With MVC 2, should Web User Controls be avoided?
I'm using the default logon/register pages in my mvc 2 project ,
I'm trying to use the same aspx page for both of them ,(logon & register ) for this perpas I have created a prtial view from the register controller and load it into the logon page, how ever when the user just click without any data in any field , I'm getting this error ,
The model item passed into the dictionary is of type 'JvTake3.Models.LogOnModel', but this dictionary requires a model item of type 'JvTake3.Models.RegisterModel'.
I would like to Emphasize that in my partial view there is :
I am creating a web user control for a simple poll. I am currently registering it on the page and then referencing it via tagprefix.
The form for the poll is in basic html (no server controls) and is in the front-end of the web control. How can I change the look of the user control depending on the settings passed into it? Is this possible without using server controls?
I am tring to add a user control to do a search. this user control is to be used on the home page and for example /category-page.where do I write the code for data capturing. is there a way to force the user control to submit to a HomeController or the controller I want?
[AcceptVerbs(HttpVerbs.Post)] public ActionResult Search(string key)
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)?
I have the user control and web page. When I place user control in the web page and in design time, it cannot view and error is "System.Web.UI.UserControl does not have a public property named 'ContentTemplate". It seems not related of error message.