.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Need to set "ValidateRequest" on the basis of user role

Posted By:      Posted Date: September 05, 2010    Points: 0   Category :ASP.Net
I am trying to implement a code which will switch Validation request on the page on the basis of user role. If accessed by power user, it should allow html entries in textboxes otherwise restrict. I want to implement something like below..I would really appreciate if proper idea/code is shared. if (Page.IsPostBack == false) { if (Session["userrole"].toString()="admin" { SetValidateRequest(false); // Sample Function to set validation } else { SetValidateRequest(true); // Sample Function to set validation } }  

View Complete Post

More Related Resource Links

Need help with setting up SQL Server 2008 for role/user management


I've posted my problem in a few other categories.  Sorry for that.  I didn't see the security category until now.

I'm trying to use ASP.NET's built-in role/user management for a couple ASP.NET MVC 2 sites.  I'm using the MVCMusicStore as my guide.  I click on the Configuration Tool as the tutorial suggests, which launches the site administration page.  Unfortunately when I click on the security tab, I get an error that it cannot connect to the data store.  Attempting to test the AspNetSqlProvider gives me a similar error.

I've run the aspnet_regsql program as the error message suggested, and I have a role/user management database ready to go on the server.  The proper tables are constructed, and all that.  The configuration tool still doesn't see the data store.

As a test, I ran the MVCMusicStore demo in the debugger.  Its role/user management functionality worked.  I was able to add myself as a customer, and add/remove items from my cart with no errors or exceptions.  However, when I attempted to access its security tab in the configuration tool, I received the same error as I get for my own project.  How is it possible that role/user management works, but the configuration tool cannot change its settings?

Any suggestions on how I can get the configuration t

asp.net,c#,user role and rights,menu

hi friendsi want to develope general code or module or structure of web application wich handle multiple user ,their role and right, and according to their rights and role menu will be display.so i can integreate it in any website. kindly provide me solution for asp.net 3.5,C# working environment, and sqlserver 2005 environment.what is the structure for database? i want only one database not asp.net database. can i make login control type assembly(dll)?how?Thanking you 

infopath 2003 user role error

hi, i'm trying to create a user role for my form in infopath 2003. but when i add a user and click on the icon next to the texbox it gives me this error: The program cannot open the required dialog box beacause no locoation can be found

user mapping to a database and role membership to that database

When assigning a 'user mapped Login' to a database and role membership to that database, is it redundent to check/enable db_datareader, db_datawriter as well as db_owner or will check/enable db_owner become all that is necessary to provide role membership to the database?

user role on sharepoint custom list

hi, can i set up a user role for a custom list form in sharepoint services 3 i want to use the "submit new absence" form. but i need to modify the form in a way that when a user open the form it fills the user his name or login name in the fields. and that the approver or "assigned to field" also is filled with the approvers name. i think i need to use a query for that, but how can i apply it to the fields of the absence list form

Changing a users role with RadioButtons (User is always in single role)

So I have a set of 5 radio buttons corresponding to the roles a user can have on my website.  I have been successfully able to retreive what radio button needs to be checked for the role the user is currently in... string username = Request.QueryString["username"]; // Get Access Levels and populate radio buttons. if (Roles.IsUserInRole(username, "Banned") == true) { RadioButton4.Checked = true; } if (Roles.IsUserInRole(username, "Member") == true) { RadioButton1.Checked = true; } if (Roles.IsUserInRole(username, "FOB_Employee") == true) { RadioButton2.Checked = true; } if (Roles.IsUserInRole(username, "FOB_Administrator") == true) { RadioButton3.Checked = true; } if (Roles.IsUserInRole(username, "Webmaster") == true) { RadioButton5.Checked = true; } My problem is I do not know what to do with the actual procedure of changing the roles based on the new radio button selection.  I have tried many different methods, including using if statements to check if the user is currently in the role, remove him/her from that roll, and then add the user to the newly selected role.  It appears, from my testing, that you can not

CreateUserWizard creating dupicate user while assigning Role.

protected void CreateUserWizard1_CreatedUser(object sender,  EventArgs e){Roles.AddUserToRole((sender as CreateUserWizard).UserName, "Customers");} CreateUserWizard is creating dupicate user while assigning Role.How can we assign Role without duplicating user record? I've observed ApplicationID for assigning Role is Differenent than Creating New User, so when ever Role assigning comes in, it creates  same user again with new UserID. Is it related to Web.Config in some way? As when I try to create user from "VisualStudio/Website/ASP.net Configuration" even then two users with same usernames are entered in aspnet_users with Different ApplicationID and UserID. One user has Role and another duplicate user is without Role status of IsApproved=1.Please help me to resolve this issue.Thanks!  

ScaffoldTable(false) if user is not in the admin role.


Hi guys,

I my dynamic data application, I made ScaffoldTable(false) on some of the table in a seperate partial classes. I am using linq to sql classes for my tables and Also I am using sql membership on my application.

what I want to do is that I need to make the following table's ScaffoldTable as false, if the user is not in the admin role. How can I do that ?


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Configuration;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Xml.Linq;
using System.Linq.Expressions;
using System.Reflection;

/// <summary>
/// Summary description for CategoriesPhoto
/// </summary>

public partial class CategoriesPhoto
public class CategoriesPhotoMetaData


Restrict user with sys admin role to execute a query


Hi All


I want to restrict  a user with sys admin server role to execute a query. or is there any possibility to drop the query before it get executed (after parsing). I know i can do this using SSMS SET NOEXEC ON | OFF in Query Analyzer.

But how can i implement this when ever sysadmin user executes a particular query.


Mohd Sufian www.sqlship.wordpress.com Please mark the post as Answered if it helped.

Issue trying to remove user from role that is no longer available.


Using tutorials and some examples of handling membership permission on our site, i have a page that was built using examples found in those pages.. Anyway, now that it is all setup and working ran into first issue.. If a role is setup with a space in the name like this ("Read Only") then you get an error when you try to add someone to that role. But if i change it to be ("ReadOnly") it works fine and no issues..


                        <asp:GridView ID="GridViewRole" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSourceRoleObject"
                            DataKeyNames="RoleName" CellPadding="3" CellSpacing="3" AllowPaging="True">
                                <asp:CommandField ShowDeleteButton="True" DeleteText="Delete Role" />
                                        <asp:Button ID="Button1" runat="server" CausesValidation="false" Width="500px" OnClick="ToggleInRole_Click"
                                            Text='<%# ShowInRoleStatus( (string

Adding user to SSAS server role not working


I have SQL Server 2005 SP3 installed on  Windows 7


 I’m trying to deploy a SSAS project and get the message


“Either the user, Ron-laptop\ron, does not have access to the analysis services Project2 database, or the database does not exist”


Following recommendations in the forum I’ve used SSMS to view the properties > security of the SSAS connection and am trying to add myself to “The server role is used to grant server-wide security privileges to a user” role


How to redirect logged in user based on role



I want to know how can i redirect a user to a different page when he tries to access a page restricted to another role?

The scenario is as follows:

 I have a folder "Gestao" that only allows users in role "Administrator"

            <!--<allow roles="Administrators"/>
        <deny users="*"/>-->

If an anonymous user tries to access that folder he is redirected to the login page, but if a logged in user whose role is "friend" tries to access this folder he is also redirected to the login page. I want to redirect him to a page showing a message that he has no permission to access that page/area.

How can I do that? Should i have code on the Page_load event of the login page checking the user role and then redirect him to the correct page? Or is there some otherway to do this?

Thanks in advance!
Rui Palhinhas


redirects to default page if user doesn't have appropriate role


Hi All,


How to redirects to default page if user doesn't have appropriate role in particular forms Using Asp.net authentication.


Thanks in Advance


MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).

How to track the changes of user contacts(colleagues) by using SharePoint API

We might have seen colleague tracker web part which keep tracks the changes made in our contacts/colleagues details like profile/lists/sites. The same tracking mechanism can be implemented by using MOSS API in any custom web part/ web control/ feature/web service...

UserProfile.GetColleagueChanges is the method which returns all changes happened with the contacts, this method also accepts a Query (UserProfileChangeQuery) where we can specify different parameters to filter the changes
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend