Skip to main content

Posts

#MVC Authorize Attribute

Authorization is the process of determining the rights of an authenticated user for accessing the application's resources. The Asp.Net MVC Framework has a AuthorizeAttribute filter for filtering the authorized user to access a resource. Authorize Attribute Properties Properties Description Roles Gets or sets the roles required to access the controller or action method. Users Gets or sets the user names required to access the controller or action method. Filtering Users by Users Property Suppose you want to allow the access of AdminProfile to only shailendra and mohan users then you can specify the authorize users list to Users property as shown below. [ Authorize ( Users = "Raj,Deena,Siva,Gow" )] public ActionResult AdminProfile () { return View (); } Filtering Users by Roles Property Suppose you want to allow the access of AdminProfile action to only Admin and SubAdmin roles then you can specify the authorize roles...

#.Net Globalization and Localization

What is Globalization and Localization? Globalization is the process of designing the application in such a way that it can be used by users from across the globe (multiple cultures). Localization, on the other hand, is the process of customization to make our application behave depending on the current culture and locale. These two things go together.

#Framework Net Architecture and .Net Framework basics

What is the .NET Framework? The .NET Framework is a new and revolutionary platform created by Microsoft for developing   applications .    It is a platform for application   developers . It is a Framework that supports Multiple Language and Cross language integration. IT has IDE (Integrated Development Environment). Framework is a set of utilities or can say building blocks of your application system. .NET Framework provides GUI in a GUI manner. .NET is a platform independent but with help of Mono Compilation System (MCS). MCS is a middle level interface. .NET Framework provides inter-operability between languages i.e. Common Type System (CTS) . .NET Framework also includes the .NET Common Language Runtime (CLR), which is responsible for maintaining the execution of all applications developed using the .NET library. The .NET Framework consists primarily of a gigantic library of code. Definition:  A programming infrastructur...

#c# extension methods

What are extension methods? Extension methods enable you to add methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type.  An extension method is a special kind of static method, but they are called as if they were instance methods on the extended type. How to use extension methods? An extension method is a static method of a static class, where the "this" modifier is applied to the first parameter. The type of the first parameter will be the type that is extended. Extension methods are only in scope when you explicitly import the namespace into your source code with a using directive. public static class MyExtension {         public static string ToMyStandard (this string stdString)         {             return "MYSTR-" + stdString;         }     }  string ss = "data";  @ViewBag.MyData = ...

#C# String is Immutable in C#

There is a term called immutable, which means the state of an object can't be changed after is has been created.  A string is an immutable type. The statement that a string is immutable means that, once created, it is not altered by changing the value assigned to it. If we try to change the value of a string by concatenation (using + operator) or assign a new value to it, it actually results in creation of a new string object to hold a reference to the newly generated string. It might seem that we have successfully altered the existing string. But behind the scenes, a new string reference is created, which points to the newly created string. string s1="Hi"; string s2=s1; s2=s2+"Raj"; s1  -> pointer to data "Hi" s2  -> pointer to date "Hi" -> pointer to data "Hi Raj" here s2 is pointing to new data. that is s2 pointer is changed.(Immutable)

#c# String is a reference type. Why?

The data type Integer is a  value type , but a String is a  reference type .  Why ? A String is a reference type even though it has most of the characteristics of a value type such as being immutable and having == overloaded to compare the text rather than making sure they reference the same object. Why a string is just a value type Why isn't a string just a value type, then?   First of all let's understand what value types and reference types are and the difference between them in a glance. The types can be classified depending on whether a variable of a specific type stores its own data or a pointer to the data. That means, instead of storing data, it stores its address. I f it stores its own data it is a value type and if it holds a  pointer  to data  elsewhere  in memory it is a reference type. Value types are stored in the Stack whereas reference types are stored in the Heap.