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

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

Basics of Attribute class and codeaccess security

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :.NET Framework
    I am using code access security for my methods which are in a class library and hosted in ASP.Net process. The attribute class checks for some values in Session and sets the principalpermission appropriately. The method works fine allowing only valid threads to pass thru and exceute the method. But the problem is this happes only once and for every subsequent aspx calls does not hit the attribute class. (I guess CLR optimizes it). My problem is if the session has a different value then the attibute should behave appropriately. Now, it takes new value from Session only when I recycle my asp process and happens only once for the request. IS there a way to circumvent this? Any suggestions?

View Complete Post

More Related Resource Links

Make sure that the class defined in this code file matches the 'inherits' attribute, and that it e


Here is the page directive for the page that throws the error:

@ Page language="c#" Inherits="University.AspNet.Index" CodeFile="Index.aspx.cs" %>

The code behind file Index.aspx.cs starts like this:

using University.Framework.UI;

namespace University.AspNet

public partial class Index : University.Framework.UI.HomePage

The code behind is extending this HomePage class, which is in turn an extenstion of another class University.Framework.UI.Page, which extends the System.Web.UI.Page class.

Am I misusing the I

Advanced Basics: The ObservableCollection Class


Ken Getz shows how the CollectionChanged event lets you reflect changes to your underlying data source in your bound data controls.

Ken Getz

MSDN Magazine December 2008

Advanced Basics: The LINQ Enumerable Class, Part 2


This month Ken digs deeper into the System.Linq.Enumerable class and shows readers how to perform some magic data operations using System.Linq.Enumerable.

Ken Getz

MSDN Magazine September 2008

Advanced Basics: The LINQ Enumerable Class, Part 1.


Presented here is the LINQ Enumerable class, which allows you to manipulate data in any class that implements IEnumerable(Of T).

Ken Getz

MSDN Magazine July 2008

Security Briefs: Hashing Passwords, The AllowPartiallyTrustedCallers Attribute


Keith Brown describes how yo can hash passwords when you want to store them in your own custom database, and when to use the AllowPartiallyTrustedCallers attribure on your assembly.

Keith Brown

MSDN Magazine August 2003

Can serialize but not deserialize class containing an xs:list attribute using XmlSerializer

I have a simple serializable class along the lines of: [Serializable] [XmlType] public class MyClass { [XmlAttribute("values")] public int[] Values { get; set; } } If I create an instance of this class with Values set to an empty collection the XmlSerializer class produces this output as expected: <?xml version="1.0" encoding="utf-16" ?> <MyClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" values="" /> However, deserializing this exact output throws a System.FormatException: Input string was not in a correct format. Shouldn't the XmlSerializer be able to deserialize this, since it produced the xml string in the first place?

Security permission for a key attribute which belongs to a parent-child hierarchy.



I have a dimension with a parent-child hierarchy on the key attribute and another attribute for the parent. I also want to declare a role with a permission to view only a specific member of that dimension, but it doesn't let me define a restriction on the key attribute and says I must define the equivalent restriction on the parent attribute. The problem is that I don't know how to accomplish that because I must use a specific value, so I can't restrict it using this value's parent or children. I might be stupid, but I really have no idea how to do it...


Version of security class in rssrvpolicy.config


When I add a custom assembly to SSRS, I got the following error,

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I checked rssrvpolicy.config and Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\security.config,

The one from security.config is,



SecurityClass Name="SqlClientPermission"

class defined in this code file matches the 'inherits' attribute


Hello am very new to asp and web programming

am trying to do a login page that reads from an sql database ... so i found a c# code and when i compile it and run it with visual studio

i get this error:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Source Error:

Line 1:  using System;
Line 2: using System.Data;
Line 3: using System.Configuration;

and here is my full cs code in the file login.aspx.cs

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.We

Only Web services with a [ScriptService] attribute on the class definition can be called from script


I have created a web service.  When I check the service directly from it's web page it works correctly. Here's what the code looks like:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Configuration;
using System.Runtime.Serialization;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Text;
using Microsoft.SharePoint;
using System.Collections;

namespace MDA.WebParts.SPRolodex_Web_Service
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class SPRolodex_Web_Service : System.Web.Services.WebService

        public SPRolodex_Web_Service()


        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool ListExi

How can I generate property set event with attribute class?


I want to code design like below;

class Sample
            public string Prop1

            void MyChangesDelegate()

is that possible?

SharePoint Tutorial - Security

Security in SharePoint is comprised of users, groups and roles.

Users, Groups and Roles

A user account comes from the authentication system. For example, if Active Directory is used to authenticate then the user accounts will come from it.

There are two types of groups SharePoint uses: domain groups and SharePoint groups.

Learning Jquery: The Basics

First lets go over the basics of jquery coding. All jquery starts with a "$" no matter what! In all of your jquery documents ( which is just a javascript file) you need the following code in your document, this code is to load your functions if you do not add this code your jquery will be useless.

Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.

Creating a Simple Class in C#

The second article in the C# Object-Oriented Programming tutorial describes how classes are created in C# and how behaviour, in the form of publicly visible and private, hidden methods can be added. This demonstrates some of the uses of encapsulation

Static Class for Beginners

In general, the members of a class can be accessed by instance of that class when they are in public, but there comes a situation to access or call members of a class without an instance and this can be achieved by declaring them as static
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