Web Forms :: Authenticate Current Logged In User In Asp 3.5 - Error CS1061

Jan 26, 2010

I want to check that the user trying to log-in is authenticated and it belongs to a certain role. For this I have wrote the following code

protected void btnLoginButton_Click(object sender, EventArgs e)
{
/
if (this.User.Identity.IsAuthenticated && this.User.IsInRole("Admin"))
{
Response.Redirect("~/Admin/Default.aspx");
}
if (this.User.Identity.IsAuthenticated && this.User.IsInRole("Editor"))
{
Response.Redirect("~/Editor/Default.aspx");
}
if (this.User.Identity.IsAuthenticated && this.User.IsInRole("Moderator"))
{
Response.Redirect("~/Moderator/Default.aspx");
}
}

But when I ran this code it gave me this error error CS1061: 'Page' does not contain a definition for 'User' and no extension method 'User' accepting a first argument of type 'Page' could be found (are you missing a using directive or an assembly reference?) I have already added following directives to cs page-

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

Can anybody tell what directie I should add for "this.User" <P.S> My application is web based and it is in ASP.Net 3.5(C#).

View 6 Replies


Similar Messages:

Security :: Authenticate User Logged In One Website And Redirect To Other?

Apr 8, 2010

i want to interlink between 2 applications of mine.. suppose a user has logged in one of my application and me store his username and password in cookies...nd nw i want to use those values in the cookies to log-in in other website without entering the username and password again for the other website. i mean to i want to skip the login page of other website.

protected void btnclick_Click(object sender, EventArgs e)
{
HttpCookie username = new HttpCookie("UserName", "a");
HttpCookie password = new HttpCookie("Password", "a");
Response.Cookies.Add(username);
Response.Cookies.Add(password);
Response.Cookies["UserName"].Expires = DateTime.Now.AddHours(1);
Response.Cookies["Password"].Expires = DateTime.Now.AddHours(1);
}

this is the code for storing values in cookie on click of a button. nw in 2nd application on page load i am using this code.

HttpCookie userName = Request.Cookies.Get("UserName");
HttpCookie password = Request.Cookies.Get("Password");
if (userName != null && password != null)
{
if (Membership.ValidateUser(userName.Value, password.Value))
{
FormsAuthentication.RedirectFromLoginPage(userName.Value, false);
}
}

here m able to get the username nd password but don't how to validate that username and password so that i can skip the login page of this application..m not sure about the code in BOLD above if its rite or worng.. and for Login i am using ASP login Control
in both applications.

View 3 Replies

Web Forms :: How To Get The Current Logged In User's Email Address

Mar 18, 2010

How to retrieve the current authenticated logged in user's email address who is accessing the page.

I have managed to do it with users. How to get the current authenticated user's email address if that makes sense.

Here is my aspx code:

[Code]....

and my VB script:

[Code]....

Somebody suggested that I should run a query. If you know the user name accessing the page, surely you can take that information, insert it into a query to find out the email address of the user accessing the page. Sounds great but don't have a clue how to do it.

View 2 Replies

Web Forms :: Current Logged In User's Information In Sharepoint List?

Oct 8, 2010

in order to prepopulate some user information, i used query to search the sharepoint list. my question is how to search loggin user's info in the list. i used following testing query function. it works fine. however, it can only search specific text, cannot be changed according different user.

[Code]....

View 1 Replies

Web Forms :: Display Online Users Except Current Logged In User In Membership

May 7, 2015

I have below code to display "list of all the online users" inside listBox using Membership function.

Code:

protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
MembershipUserCollection allUser = Membership.GetAllUsers(); // to get all the users
List<MembershipUser> onlineUsers = new List<MembershipUser>(); //creating list of online users
foreach (MembershipUser user in allUser)

[Code] ....

I want to remove that user from the list of online users, who himself has logged in. Example: if I had logged-in with UserName: Admin, then this Admin should not show to me in the list of "online users"

Tried below Code but not working:

protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
MembershipUserCollection allUser = Membership.GetAllUsers(); // to get all the users
List<MembershipUser> onlineUsers = new List<MembershipUser>(); //creating list of online users
MembershipUser m_user = Membership.GetUser(); //to get self logged-in user

[Code] ....

View 1 Replies

How To Get Current Logged In User Name

Oct 25, 2010

I thought this would be a simple task as I am trying to get the current logged in domain user name. I have the following:

[Code]....

but it ALWAYS returns nothing ""

Is there some configuration in the ASP that I have to do first?

View 3 Replies

Security :: Link To Current Logged In User?

Jan 25, 2011

I wan't to link to the current logged in user with their userid, this is for the user menu. But I don't see why my code dosen't work.Code Behind:

[Code]....

Masterpage:

<asp:LoginView
ID="LoginView1"
runat="server">
<LoggedInTemplate>
<asp:HyperLink
ID="UserProfil"
Text="Profil"
runat="server">Profil</asp:HyperLink>
</LoggedInTemplate>
</asp:LoginView>

View 3 Replies

Security :: Display Current Logged In User In A Textbox?

Feb 15, 2010

I am trying to make a Contact form exclusive for Members. So as my first field (ID=username) I would like some VB script so that when the page loads it can identify the user that is accessing the page and display it in a read-only text ready for submission by email (with the email address and text area, don't worry about these because I know how to add these).

(here is my Contact us page code, nothing special but I'll give you it just in case)

[Code]....

View 8 Replies

Architecture :: How To Save The Current Location Of Each Logged-in User

Jan 26, 2010

Let me tell you what I need to implement on my company .NET application and I will be more than glad to hear your advise how to do it:

For every user loged-in to the company website, We want to know on which page he is right now. It means, If user X is now on page "1.html", I need to save this information somewhere. If user X after 30-60 seconds going to page "2.html" I want to update it fast where he is now surfing. It means I want to be able to tell at REAL TIME, on each page, Which users are right now observing the page. This is the problem, now I'm looking for the right solution.

If some day my company website will have 400,000 user log-in at the same time, I am going to save to every one of them where he is surfing right now. Maybe I exaggerated, but we do have 45,000 users at the same time on the company web site and the number is growing. I think big so the solution for this problem will be good for a lot of users.

So, my data object for every user should keep this information somewhere:

1. User code (User Number).
2. Which page user is now observing (Page Number).

This object is going to update every 30-60 seconds by using AJAX, so it should be updated fast. It is a lot of reading/writing data. If a user want to see which other users are now on the same page as he his, he will be able to see it, just by going through the whole array of objects.

I don't need this information to be saved in DB, because it doesn't mean anything. It is temporary and changing A LOT. So, I think the right place to do it is using RAM at the the company server, using the Caching Data option. What do you think? Am I wrong?

If I am going to have a data table with lots of records and every record is going to be update every 30-60 seconds. Where should I save all this table data? I am using SQL Server 2008 to save important data as needed, but this data is not important to save, just need to use it for my purpose. Where should I save this data? I think saving it in DB is a bad idea, because of the dynamic update of records every few seconds. I am thinking about 100,000 users who update this table every few seconds. It probably going to kill my DB, so DB is not an option.

What is the right way to implement this kind of thing?

You may think of it like every page is "a chat room" and I want to know who enter now the room (the page), it doesn't have to be completely accurate in time, but approximately.

View 7 Replies

Security :: How To Get Author Of A Post As The Current Logged In User

Jan 17, 2011

The thing is that I'm creating a community fanpage, I have the membership database installed and I have created user profiles for the users, and it works fine. The thing I can't seem to find anywhere is how to capture the current logged on users username and save is as the author of a post in the database. Like right now, I'm writing a post, and when I click Post it will say it's written by Jeanz91 because I'm the user who's logged in. How do I get my site to do that?

View 3 Replies

How To Dynamically Change Session Time For Current Logged User

Oct 27, 2010

it is possible to change dynamically the session time for currently logged user. I'm communicating with a WebService which does a long-running task, and while the it sends the final response, I don't want the user to be logged out.

View 2 Replies

MVC :: Error CS1061 On RenderPartial?

Oct 29, 2010

I've got a container object that holds the various objects required by the partial views contained in a regular view. I changed from passing the entire object into each partial view to passing just the object the view needs, but I ran into an odd error.I'll post the code. The first RenderPartial that's called worked just fine. The second one, which is identical in every regard I can see but the actual contents, is the culprit. I get a HttpCompileException, stating that:

...ProjectUpdater.ascx(97): error CS1061: 'DSC.Data.Model.Shared.ProjectUpdaterInfo' does not contain a definition for 'ProjectUpdater' and no extension method 'ProjectUpdater' accepting a first argument of type 'DSC.Data.Model.Shared.ProjectUpdaterInfo'
could be found (are you missing a using directive or an assembly reference?)

Here's the view code:

[Code]....

I get intellisense for the Model.ProjectUpdater, and nothing shows up with the squiggly lines indicating an error. Here's the properties of the model class:

[Code]....

So there's the ProjectUpdater I'm getting an error saying doesn't exist. What's driving me nuts is that the first RenderPartial is working fine.

View 1 Replies

C# - Compiler Error CS1061 / How To Avoid It

Jan 8, 2010

I have the following class... Compiler Error CS1061 / how to avoid it

[code]....

View 2 Replies

Security :: Getting Compiler Error Message: CS1061

Jan 4, 2010

I am a recent convert to ASP and a fairly total n00b, which means that though I've worked with web technologies for all my life, I have no idea how ASP handles them and I'm learning step by step so I beg for some patience as my many questions may be trivial.

For example, I've followed a couple of online tutorials on creating basic authentication via web.config, however I have run into some trouble. Here is my setup:

[Code]....

and some HTML:

[Code]....

However, after compiling, the browser tells me this:

Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

Compiler Error Message: CS1061: Type `ASP.views_login_index_aspx' does not contain a definition for `ProcessLogin' and no extension method `ProcessLogin' of type `ASP.views_login_index_aspx'
could be found (are you missing a using directive or an assembly reference?)

View 4 Replies

Get Exception Error If Logged In User Is Inactive?

Oct 6, 2010

If a logged in user is inactive on the page for more than 20 minutes and thenclicks a button to cause post back they get the error below.Server Error in '/' Application.Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.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.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster

View 5 Replies

Mvc 3 And Vs2010 With Error CS1061: 'object' Does Not Contain A Definition For Model?

Mar 5, 2011

My code all worked under mvc 2 with vs2008. It didn't work when I converted it to mvc 3 and vs2010. Here is one of errors: Compiler Error Message: CS1061: 'object' does not contain a definition for 'LabelText' and no extension method 'LabelText' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

Source Error: [Code]....

<%
@
Page
Language="C#" [code]....

View 4 Replies

Forms Data Controls :: Compiler Error Message "CS1061: To Do With Gridview Method" When Creating Shopping Cart

Apr 5, 2010

I am using an application from a book for a shopping application , to adapt for my own learning, but there seems to be a problem with the shopping cart page. This is a section I have not changed as there is no need to but there is an error. In the code behind the only thing new is the namespace:

namespace OIClothing
{
public partial class Cart : System.Web.UI.Page
{
ShoppingCart cart; // it doesn't like this, giving the debug message the type or namespace 'Shopping Cart" could not be found
protected void Page_Load(object sender, EventArgs e)
{
CheckTimeStamps();
if (Session["cart"] == null)
{
cart = new ShoppingCart();
Session["cart"] = cart;
}
else
{
cart = (ShoppingCart)Session["cart"];
}
GridView1.DataSource = cart.GetItems();
if (!IsPostBack)
GridView1.DataBind();
btnCheckOut.Enabled = (cart.Count > 0);
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
cart.DeleteItem(e.RowIndex);
GridView1.DataBind();
}

but when running the page, this error is given: CS1061: 'ASP.cart_aspx' does not contain a definition for 'GridView1_RowDeleting' and no extension method 'GridView1_RowDeleting' accepting a first argument of type 'ASP.cart_aspx' could be found (are you missing a using directive or an assembly reference?)

View 17 Replies

Security :: How To Get The Current Logged In UserId Value

Aug 20, 2010

I'm trying to get the current logged in UserId Value, using this code

[code]...

But, I getting an error (NullReferenceException), I did set a url authorization on the page that i try to get the logged in user information, witch is info.aspx, and I made the login.aspx control to be redirected to the info.aspx after the login process, But the info.aspx only shows me (access in denied), how can i make this page knows that i am already logged in?

View 3 Replies

Using EWS From Within A Website, Is It Possible To Use The Current Logged In Users Identity?

Feb 20, 2010

I have a web application using Forms authentication provided by AD. I would like to know if it's possible to use EWS to send mail as the currently logged in user without having to supply credentials, or; would I be required to set up an account with impersonating access which will send mail on behalf of the currently logged in user?

View 1 Replies

How To Get Current Logged In UserID In Aspnet Mvc Membership

May 7, 2010

i am trying to show a list of users of my application "school", when admin logs in then he can view all the users in list but when school principals logins, he should get only users of his school, So i thought to get the current loggedIn userId first and then by that userId i'll get schoolId since userId is foreign key in school table...once i'll get the schoolId i can show the members of that school.

But my problem is how to get the UserID of currently loggedIn. I'm using MVC 1.0 Asp.Net -- "Membership" if my logic above is wrong then tell me the alternate good idea, so that principal can see only his users list.

View 3 Replies

Where In The Web Forms Lifecycle Can Re-authenticate A User

Jan 15, 2010

Here's the situation - Most of this ASP.NET Web Forms application (which uses a single master page for all pages) with Forms Authentication, has a standard session timeout, but there are some "modes" where we store an encoded cookie that links the user to their account.

I would like to manually check early on in the page lifecycle for the cookie, and if certain conditions are met, manually re-establish the user's authentication ticket/session.

Where's the best place to do this? Master page Page_Init? Global.asax BeginRequest?

View 1 Replies

Web Forms :: Account Page Shows Only Information For First Created User, Not The Info On Logged In User?

Mar 4, 2010

I have the membership provider and the create user with tow steps, one of the steps contains a custom registration form, for each created user data will be in the database, and there is an account page shows the data that the new created user did insert during the registration process on the custom registration page,

the problem, when the user is created and logged into his account page, this account page shows only the information for the first created user, not the info on the logged in user , but the logged in user data still saved in database and not showing on his account page?

This is web.confg code:

<?xml version="1.0"?>

View 22 Replies

Architecture :: Show The Current Client Logged In Only What They Have Posted To The Application?

Sep 7, 2010

I am working on an application where it stores information that different clients will be using. I need to figure out how to show the current client logged in only what they have posted to the application and not everything that has been posted to the application. Client 1 logs in and sees what they have posted; client 2 loggs in and sees what they have posted.....etc. Can anyone shed some light on this for me?

View 1 Replies

State Management :: Users Getting Logged Out Because HttpContext.Current Is Null?

Aug 19, 2010

We've got a fairly large, complex web application that uses Forms Authentication to authenticate users. Throughout the application we store and retrieve information about users in the Session object, and in some cases in cookies. In a couple places we check for the existence of the context, and if it's null we send the user back to the login page to re-establish the session. Just a quick run-down of this web app: C#, .NET 3.5, IIS 6, ASP.NET State Service to manage sessionAs for the session timer, we use our own home-grown timer, which is basically a client-side timer, which is backed up by a check to the SQL database to see when their last activity was. This seems to work well for us. It's not perfect, but it allows us to notify the user before the session times out, and allows us to be certain we're not logging a user out before their 60 minutes of inactivity is up.What's happening is that certain users are being logged out after just a few minutes. We've eliminated the timer as a cause and believe what's happening is the HttpContext.Current is null, so the user is logged out. We do not know why the HttpContext.Current is null, and I understand there are many reasons that may occur. What I'm trying to figure out is, is there any way to re-establish the context once it is null? If not, is there anything I can do at this point other than have the user login again? We're also trying to figure out a better way of managing user information (preferences, roles, flags, history, etc), but everything needs context to use, right? Cookies, sessions, cache, etc. all require a response or request, correct? hope this makes sense, because I really need help with this. I've searched the forums here, and found many posts about HttpContext.Current going null, but not a lot of solutions for this...

View 14 Replies

Web Forms :: Authenticate User When WebMethod Is Called Using JQuery

Jul 3, 2012

I check using web service that we can invoke. So, I use web method at code behind like below 

[WebMethod]public static string ReceiveWebService(string type_list, string type_accom){ 
return string.Format("Thank you ,{0} number of rows inserted!", rowsInserted);}

And check user session at load like below

if (Session["user"] == "Abhijit"){}else{Response.Redirect("Login.aspx");}

Is this process secure?

View 1 Replies







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