Click here to Skip to main content
15,892,059 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How i can show my items by default without filter on one of dropdownlists? Pin
Blue_Boy19-Apr-08 2:22
Blue_Boy19-Apr-08 2:22 
Questionhow to get <div> </div> string Pin
sugunavathysubramanian19-Apr-08 0:40
sugunavathysubramanian19-Apr-08 0:40 
AnswerRe: how to get string Pin
Guffa19-Apr-08 5:05
Guffa19-Apr-08 5:05 
Questionconfused ! Pin
Krazy Programmer19-Apr-08 0:16
Krazy Programmer19-Apr-08 0:16 
QuestionRestrict Pages......????? Pin
Syed Naushad S18-Apr-08 23:44
professionalSyed Naushad S18-Apr-08 23:44 
GeneralRe: Restrict Pages......????? Pin
ArunVijay19-Apr-08 17:53
ArunVijay19-Apr-08 17:53 
QuestionRe: Restrict Pages......????? Pin
Syed Naushad S20-Apr-08 21:27
professionalSyed Naushad S20-Apr-08 21:27 
AnswerRe: Restrict Pages......????? Pin
samMaster22-Apr-08 20:32
samMaster22-Apr-08 20:32 
Hi you can create a security object table on your database that all pages names and their access permissions. Your security object table may be for example such this:
Id(int) URL(varchr(256)) GrantAdmin(bit) GrantUser(bit) GrantPublic(bit)

You shuld insert each page url and its permission into this table and in your base page (that each page inherit from it) on page load you had to get page url and then get its permission from data base and then check user type with page permission.

protected override void OnInit(EventArgs e)
{
base.OnInit(e);

CheckAccessPermissions();
}

private void CheckAccessPermissions()
{
String applicationPath = this.Request.ApplicationPath;
String pagePath = this.Request.Path;

pagePath = pagePath.Replace(applicationPath+"/", "");
try
{
Permissions permission = GetPagePermissions(pagePath); //Permissions is a class that contain security object table columns
User user = null;//User is a class that contain user name and user role
if (!permission.GrantPublic)//if the page is not public
{
if (Context.User.Identity.IsAuthenticated)
{
user = (User)Context.Items["UserInfo"]; //Context must be set on global.asax(Application_AuthorizeRequest)
if (user.Role == Roles.Administrator) // Roles is a enum
return; //Administrator is granted to access all the pages.
else if (user.Role == Roles.User&& permission.GrantUser)
return; //User is a not admin and the page is granted for user access.
else
//the user is authenticated but does not have permission to access this page.s
Response.Redirect("~/AccessIsDenied.aspx");
}
else
{
//If the page is not public and user is not authenticated:
Response.Redirect("~/AccessIsDenied.aspx");
}
}
}
catch (FileNotFoundException)
{
throw new Exception("Access permissions to this page are not set. Page path: "+pagePath);
}
catch
{
}
} D'Oh! | :doh:
QuestionHow to call javascript function when certain condition is true Pin
rahul.net1118-Apr-08 23:24
rahul.net1118-Apr-08 23:24 
GeneralRe: How to call javascript function when certain condition is true Pin
Krazy Programmer19-Apr-08 0:24
Krazy Programmer19-Apr-08 0:24 
QuestionLayout(Absolutely position) Pin
ksaw12318-Apr-08 23:01
ksaw12318-Apr-08 23:01 
GeneralRe: Layout(Absolutely position) Pin
Krazy Programmer19-Apr-08 0:23
Krazy Programmer19-Apr-08 0:23 
Questionhow to edit string using .net with c# Pin
sugunavathysubramanian18-Apr-08 22:31
sugunavathysubramanian18-Apr-08 22:31 
AnswerRe: how to edit string using .net with c# Pin
Krazy Programmer19-Apr-08 0:21
Krazy Programmer19-Apr-08 0:21 
QuestionAccess label inside usercontrol on button click Pin
Niya18-Apr-08 22:18
Niya18-Apr-08 22:18 
GeneralPopup should not be blocked........ Pin
Deepak Nigam18-Apr-08 22:16
Deepak Nigam18-Apr-08 22:16 
GeneralRe: Popup should not be blocked........ Pin
Krazy Programmer19-Apr-08 0:19
Krazy Programmer19-Apr-08 0:19 
GeneralRe: Popup should not be blocked........ Pin
Deepak Nigam19-Apr-08 0:59
Deepak Nigam19-Apr-08 0:59 
GeneralRe: Popup should not be blocked........ Pin
varun.g19-Apr-08 0:56
varun.g19-Apr-08 0:56 
Questioncan login to remote sql server using SQL server managment Studio Express Pin
Meax18-Apr-08 22:12
Meax18-Apr-08 22:12 
AnswerRe: can login to remote sql server using SQL server managment Studio Express Pin
Krazy Programmer19-Apr-08 0:19
Krazy Programmer19-Apr-08 0:19 
GeneralRe: can login to remote sql server using SQL server managment Studio Express Pin
Meax19-Apr-08 5:36
Meax19-Apr-08 5:36 
AnswerRe: can login to remote sql server using SQL server managment Studio Express Pin
~V~19-Apr-08 0:37
~V~19-Apr-08 0:37 
GeneralRe: can login to remote sql server using SQL server managment Studio Express Pin
Krazy Programmer19-Apr-08 0:38
Krazy Programmer19-Apr-08 0:38 
GeneralRe: can login to remote sql server using SQL server managment Studio Express Pin
Meax19-Apr-08 5:40
Meax19-Apr-08 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.