Monday, May 23, 2011

Asp.net Web Config

Asp.net Config files some of the aspects and points to be remember

Purpose of the Config File in Asp.net:- The asp.net Config file is the mechanism which force the website to have common mechanism. We can fine tune our application with some configuration setting.

Configuration file is XML file.

The ASP.NET runtime processes configuration information hierarchically, proceeding from a
root common to all applications on the machine—machine.config—down to all the web.config files found in the various folders of the particular application.
Asp.Net Hierarchy :-

Machin.Config -> Web.Config -> Each folder
The first level of the configuration root is element

The section has two attributes: Path and allow Override. The Path attribute represents the virtual path to which the embedded settings apply.

The Section

Anonymous identification is a feature that assigns a predefined identity to users who connect
anonymously to an application. Anonymous identification has nothing to do with the anonymous
user you can set at the IIS level, nor does it affect the authentication mechanism of
ASP.NET. The feature is designed to work with the user profile API to simplify the way you
write code in scenarios where both authenticated and unauthenticated users can use the site.

The section will create Cookie or Coolie less token and attach it with our request.
AutoDetect Uses cookies if the browser has cookie support currently enabled. It uses the
cookieless mechanism otherwise.

UseCookie Always uses cookies, regardless of the browser capabilities.

UseDeviceProfile Uses cookies if the browser supports them, and uses the cookieless mechanism otherwise. When this option is used, no attempt is made to check
whether cookie support is really enabled for the requesting device. This is the
default option.

UseUri Never uses cookies, regardless of the browser capabilities.

The Section :-
The section enumerates the characteristics and capabilities of the supported
browsers, including mobile devices. The section is tightly coupled with the
HttpBrowserCapabilities class and MobileCapabilities, which allows the ASP.NET runtime to
gather technical information about the browser that is running on the client.


The Section
The section allows you to register application-specific HTTP handlers that take care of ad hoc
URLs invoked over given HTTP verbs. I’ll dissect the syntax and usage of the
section in the next chapter.

The Section
The section allows you to register application-specific HTTP modules that
take care of hooking up specific stages during the processing of an ASP.NET request. I’ll
dissect the syntax and usage of the section in the next chapter.

Wednesday, March 23, 2011

Find the biggest palindrome in the given string

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Palindrom
{
class Program
{
static void Main(string[] args)
{
string string1 = string.Empty;
string SubstringPali = string.Empty;
string Palindrom= string.Empty;
int Count=0;
int StartIndex;
int NextCount;
string GetPalindrom = string.Empty; ;


string1 = "asdadadasdiac aadaa erereraaggacaec";
StartIndex = 0;
foreach (char c in string1)
{
StartIndex++;
if (StartIndex <= string1.Length - 1)
{
if (string1.Substring(StartIndex).Contains(c))
{

SubstringPali = string1.Substring(StartIndex);
foreach (char cu in SubstringPali)
{
GetPalindrom += cu;
if (c == cu)
{
GetPalindrom = c + GetPalindrom;
if (CheckPalindrom(GetPalindrom))
{
NextCount = GetPalindrom.Length;
if (Count < NextCount) {
Count = NextCount;
}//if (Count < NextCount)
}// if (CheckPalindrom(GetPalindrom))
GetPalindrom = "";

break;
}//if (c = cu)
}// foreach (char cu in SubstringPali)

}// if (string1.Substring(StartIndex).Contains(c))
}//(StartIndex <= string1.Length - 1)

}// foreach (char c in string1)
Console.Write(" The max count of the palindrom is ={0}", Count);
Console.Read();
}

static bool CheckPalindrom(string Palindrom)
{
int Counter;
string RevPalindrom=string.Empty;
if (Palindrom.Length > 1)
{
for (Counter = Palindrom.Length - 1; Counter >= 0; Counter--)
{
RevPalindrom += Palindrom[Counter];
}
}
if (RevPalindrom == Palindrom)
{

return true;
}
else
{
return false;
}
}
}
}

Saturday, January 15, 2011

Custom MembershipProvider

Custom MembershipProvider

Following are the steps to configure your Windows predefined User Access mecanisum . following are the screen shots and steps how to configure SqlMembershipProvider with different data base instade of the Aspnet.mdb Sata Base

Step 0 Configure your data base with aspnet_regsql

Step 1 Create Class

This class will help to create our own member ship configuration with database.

The overridable method CreateUser will help to create new user in the data base

public class NGOSqlMembershipProvider : SqlMembershipProvider

{

public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)

{

if (username.ToLower() == password.ToLower())

{

status = MembershipCreateStatus.InvalidPassword;

return null;

}

else

{

return base.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, out status);

}

}

}

Setp 2 add machine key and algorithm which will use for generating the encryption in of our password

<machineKey validationKey="287C5D125D6B7E7223E1F719E3D58D17BB967703017E1BBE28618FAC6C4501E910C7E59800B5D4C2EDD5B0ED98874A3E952D60BAF260D9D374A74C76CB741803" decryptionKey="5C1D8BD9DF3E1B4E1D01132F234266616E0D5EF772FE80AB" validation="SHA1"/>

Step 3 Create connection string in web.config file this connection string we are going to pass to custom SqlProvider

<connectionStrings>

<add name="NgopediaConnection" connectionString="Data Source=SHREYAS-PC;Initial Catalog=DEMOTEST ;User ID=sa;Password=t#d98^55;"/>

<add name="NewConnectionstring" providerName="AspNetSqlProvider"

connectionStrings>

Step 4 Now the most important thing to update the configuration setting in the config file. Using this configuration setting login controls can access data

Note:- The type key word is very important in this we need to specify the class which is inherited by SqlMembershipProvider Class with fully qualified name should be there.

<add name="NgoNetSqlProvider"

connectionStringName="NgopediaConnection"

applicationName="/"

enablePasswordRetrieval="true"

enablePasswordReset="true"

requiresQuestionAndAnswer="true"

requiresUniqueEmail="true"

passwordFormat="Encrypted"

maxInvalidPasswordAttempts="5"

passwordAttemptWindow="10"

minRequiredPasswordLength="5"

minRequiredNonalphanumericCharacters="0"

type="NGOPEDIA.NGOSqlMembershipProvider"/>

and Your ready with your Custom MemberShip provider


Sunday, December 12, 2010

Interview Question

1) Tell me about validation Control
2) How do you expose the property on the master page
2) Ajex how the java script works with the background
3) what is protected internals
4)What is need of Page.IsValid
5) What is Extension Method? Why we use it ? what is the bad thing about it
6) What is thread safty ?
7) Can we post on my server and diffrent server with html page.
8) can you change the master page Html controls image dynamically ?
9) What is multi threading
10) if my program is having diffrent culture and i used the resource file then whtat is the best way to use it . is there any work arround
11) What is satellite assembly
12) what is mutable and nonmutable string
13)how can you stop class to be not inheriting
14) how you can make less foot print in any advertisement
15)what is nullable variable
16) can value type store null value
17)what is light Weight Transaction
18)what is DSL ? explain
19)what is software factory pattern ? gives us any windows example
20)what is WSDL ?
21)why we use WSDL / or in which senarow we can use WSDL?
22)what is late binding
23)why we use overriding
24)Explain web services in three sections
Services Section
binding Section
third party section
thuse three section of wsdl document tell you where services located how communicat with it and what it will do

Wednesday, January 28, 2009

Reference type and value type

When u creates a Reference type and value type object Reference type values are store in the heap
Value types are sore in the stack and in between the both maintain the cross reference between them (if reference contains reference of other object then it will only contain reference of other object in it )

Value type instances are usually allocated on a thread's stack (although they can also be embedded in a reference type object).(boxing and unboxing Concept in .net)
Reference type variables contain the memory address of objects in the heap. By default,when a reference type variable is created, it is initialized to null, indicating that the reference type variable doesn't currently point to a valid object.
When you assign a value type variable to another value type variable, a field-by-field copy is made. When you assign a reference type variable to another reference type variable, only the memory address is copied.
If u want to declare type as value type then check following conditions
Instances of the type are small (approximately 16 bytes or less).
Instances of the type are large (greater than 16 bytes) and are not passed as method parameters or returned from methods.