5 April 2012

ASP.NET Impersonation


ASP.NET Impersonation


When using impersonation, ASP.NET applications can execute with the Windows identity (user account) of the user making the request. Impersonation is commonly used in applications that rely on Microsoft Internet Information Services (IIS) to authenticate the user.

ASP.NET impersonation is disabled by default. If impersonation is enabled for an ASP.NET application, that application runs in the context of the identity whose access token IIS passes to ASP.NET. That token can be either an authenticated user token, such as a token for a logged-in Windows user, or the token that IIS provides for anonymous users (typically, the IUSR_MACHINENAME identity).


You control impersonation using the identity configuration element. As with other configuration directives, this directive applies hierarchically. A minimal configuration file to enable impersonation for an application might look like the following example:

< configuration >
  < system.web >
    < identity impersonate="true"/ >
  < /system.web >
< /configuration >
You can also add support for specific names to run an application as a configurable identity, as shown in the following example:

< identity impersonate="true" 
  userName="contoso\Jane" 
  password="********" / >

ASP.NET Authorization


ASP.NET Authorization


Authorization determines whether an identity should be granted access to a specific resource. In ASP.NET, there are two ways to authorize access to a given resource:
  • File authorization   File authorization is performed by the FileAuthorizationModule. It checks the access control list (ACL) of the .aspx or .asmx handler file to determine whether a user should have access to the file. ACL permissions are verified for the user's Windows identity (if Windows authentication is enabled) or for the Windows identity of the ASP.NET process. For more information, see ASP.NET Impersonation.
  • URL authorization   URL authorization is performed by the UrlAuthorizationModule, which maps users and roles to URLs in ASP.NET applications. This module can be used to selectively allow or deny access to arbitrary parts of an application (typically directories) for specific users or roles.

    The following example grants access to the Kim identity and members of the Admins role, and denies access to the John identity (unless the John identity is included in theAdmins role) and to all anonymous users:
    
    
    < authorization >
      < allow users="Kim"/ >
      < allow roles="Admins"/ >
      < deny users="John"/ >
      < deny users="?"/ >
    < /authorization >

    The following authorization section shows how to allow access to the John identity and deny access to all other users:

    < authorization >
      < allow users="John"/ >
      < deny users="*"/>
    < /authorization >
      
    
    The following example allows all users to perform an HTTP GET for a resource, but allows only the Kim identity to perform a POST operation:
    < authorization >
      < allow verbs="GET" users="*"/ >
      < allow verbs="POST" users="Kim"/ >
      < deny verbs="POST" users="*"/ > 

4 April 2012

HTTP Status Code



HTTP Status Code 

HTTP/1.1 defines unique status codes and reasons. A
reason is nothing more than a very brief description of the status code. Table 1-3 shows a list
of common status codes and reasons.


Status Code Reason
100 Continue
200 OK
201 Created
300 Multiple Choices
301 Moved Permanently
302 Found
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
407 Proxy Authentication Required
408 Request Time-out
413 Request Entity Too Large
500 Internal Server Error
501 Not Implemented



3 April 2012

Session State Mode in Asp.net

Session State Mode in Asp.net

If your application needs to scale to thousands of users, then you should strongly consider
using the client for storing application state. Removing this burden from the server frees
up resources, allowing the server to process more user requests. ASP.NET provides several
techniques for storing state information on the client. These include the following:

View state ASP.NET uses view state to track values in controls between page requests.
You can also add your own custom values to the view state.
Control state Control state allows you to persist information about a control that is
not part of the view state. This is useful to custom control developers. If view state is
disabled for a control or the page, the control state will still function.
Hidden fields Like view state, HTML hidden fields store data without displaying that
data to the user’s browser. This data is presented back to the server and is available
when the form is processed.
Cookies A cookie stores a value in the user’s browser. The browser sends this value
with every page request to the same server. Cookies are the best way to store state
data that must be available for multiple webpages on a website.
Query strings A query string is a value that is stored at the end of a URL. These
values are visible to the user through his or her browser’s address bar. Use query
strings when you want a user to be able to use email or instant messaging to store
state data within a URL.

The following example shows settings in a Web.config file that cause the session state to
be stored in a SQL Server database identified by the specified connection string.
< configuration >
< system.web >
< sessionState
mode="SQLServer"
cookieless="true"
regenerateExpiredSessionId="true"
timeout="30"
sqlConnectionString="Data Source=MySqlServer;Integrated Security=SSPI;"
compressionEnabled="true"
stateNetworkTimeout="30" />

Client-Side State Management in Asp.net

Client-Side State Management in Asp.net

If your application needs to scale to thousands of users, then you should strongly consider
using the client for storing application state. Removing this burden from the server frees
up resources, allowing the server to process more user requests. ASP.NET provides several
techniques for storing state information on the client. These include the following:

View state ASP.NET uses view state to track values in controls between page requests.
You can also add your own custom values to the view state.

Control state Control state allows you to persist information about a control that is
not part of the view state. This is useful to custom control developers. If view state is
disabled for a control or the page, the control state will still function.

Hidden fields Like view state, HTML hidden fields store data without displaying that
data to the user’s browser. This data is presented back to the server and is available
when the form is processed.

Cookies A cookie stores a value in the user’s browser. The browser sends this value
with every page request to the same server. Cookies are the best way to store state
data that must be available for multiple webpages on a website.

Query strings A query string is a value that is stored at the end of a URL. These
values are visible to the user through his or her browser’s address bar. Use query
strings when you want a user to be able to use email or instant messaging to store
state data within a URL.



28 March 2012

Web Application Projects VS Web Site Projects in Asp.net


Web Application Projects VS Web Site Projects in Asp.net


Area
Web application projects
Web site projects
Project file structure
A Visual Studio project file (.csproj or .vbproj) stores information about the project, such as the list of files that are included in the project, and any project-to-project references.
There is no project file (.csproj or .vbproj). All the files in a folder structure are automatically included in the site.
Compilation
·         You explicitly compile the source code on the   computer that is used for development or source control.
·         By default, compilation of code files (excluding   .aspx and .ascx files) produces a single assembly.
·         The source code is typically compiled dynamically (automatically) by ASP.NET on the server the first time a request is received after the site has been installed or updated.
You can precompile the site (compile in advance on a development computer or on the server).
·         By default, compilation produces multiple assemblies.
Namespaces
Explicit namespaces are added to pages, controls, and classes by default.
Explicit namespaces are not added to pages, controls, and classes by default, but you can add them manually.
Deployment
·         You copy the assembly to a server. The assembly is produced by compiling the application.
·         Visual Studio provides tools that integrate with   the IIS Web deployment tool to automate many deployment tasks.
·         You copy the application source files to a computer that has IIS installed on it.
·         If you precompile the site on a development computer, you copy the assemblies produced by compilation to the IIS server.
·         Visual Studio provides tools for deployment, but they do not automate as many deployment tasks as the tools available for Web application projects.


Difference between 32 bit and 64 bit processor

Difference between 32 bit and 64 bit processor

What is a Bit ?
A bit or binary digit is the basic unit of information in computing and telecommunications; it is the amount of information that can be stored by a digital device or other physical system that can usually exist in only two distinct states. These may be the two stable positions of an electrical switch, two distinct voltage or current levels allowed by a circuit, two distinct levels of light intensity, two directions of magnetization or polarization, etc.



What is the difference between 32-bit and 64-bit versions of Windows? 
The terms 32-bit and 64-bit refer to the way a computer's processor (also called a CPU), handles information. The 64-bit version of Windows handles large amounts of random access memory (RAM) more effectively than a 32-bit system.

What are the Advantages of a 64bit Processor?
  1. The 64bit processor gives more greater performance then 32bit Processor.
  2. Allowing for the addressing of more of RAM, 64-bit processing can improve video encoding and decoding, CAD, VMs and some other applications.
  3. Ability to address memory amounts over four GB, and up to 16 exabytes
What are the Disadvantages of 64bit Processor?
  1. You’re currently not able to take full advantage of the technology because the software vendors haven’t made the switch from 32-bit to 64-bit processors.
  2. Most AMD Athlon 64 bit processors are expensive, with prices sure to go down in the future.

Implementing OAuth validation in a Web API

 I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...