Daily Tips- Tip #4 - How will you kill a user's session variable explicitly?

Wednesday, July 8, 2009


Session.Abandon()


www.codecollege.NET

What base class do all Web Forms inherit from?


System.web.UI.Page class.


www.codecollege.NET

Which Authentication methods are based on cookies?


1. Forms
2. Passport


www.codecollege.NET

Which Authentication method require Active Directory?

Digest.


www.codecollege.NET

What area the differences between Global.asax and Web.Config?

























Sno
global.asax
web.config
1 Class File Its an XML file
2 There can be only one for an application there can be many if under different sub-folders
3
Can have Application
and Session events

Can't
4
Need
to be recompiled when changes are made
No need to compile
when changes are made.


www.codecollege.NET

What are test cases you should go through in unit testing?


You need to check 3 test cases, which are the following,

1. Positive test cases (correct data, correct output)

2. Negative test cases (broken or missing data, proper handling)

3. Exception test cases (exceptions are thrown and caught properly)


www.codecollege.NET

What are the different Debugging tools which come with .NET ?


Two debugging tools come with .NET, they are :


1. CorDBG
– command-line debugger


2.  DbgCLR – graphic debugger.


www.codecollege.NET

What are the differences between const and readonly ?

























Sno
const
readonly
1 Can't be static. Can be instance level or static
2 evaluated at design time evaluated at run time
3
Initialized at declaration

Initialized at declaration and in constructor
4
must be of integral type or enumeration
In addition it can have complex types with new keyword and
enumerations are not allowed


www.codecollege.NET

How can you tell the application to look for assemblies at the locations other than its installed location?

You can do that by adding the following entry in the web.config file,


<probing privatePath="c:\yourlibrary; bin\debug" />
www.codecollege.NET

What’s the difference between authentication and authorization?

what is Authentication?


Is a process by which the system decides whether the user is valid to login to the site as a whole.


what is Authorization?


Is a process by which the system decides which are the areas and functionalities the user is allowed to access, at the component level.
www.codecollege.NET

How to download webpage using asp.net and c# ?

See the following code,

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;

namespace DownloadingFile
{
class Program
{
static void Main(string[] args)
{
WebRequest reqFile = WebRequest.Create("http://www.codecollege.net/2009/07/cloud-computing.html");

WebResponse resFile = reqFile.GetResponse();

Stream smFile = resFile.GetResponseStream();
// Output the downloaded stream to the console
StreamReader sr = new StreamReader(smFile);
string line;
while ((line = sr.ReadLine()) != null)
Console.WriteLine(line);
Console.Read();
}
}
}
www.codecollege.NET

Cloud Computing


A good article on cloud computing,

Cloud Computing


www.codecollege.NET

How to read and write from a text file using c#.net ?

See the following sample,

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ReadWriteFromTxt
{
class Program
{
static void readFile()
{
FileStream fsEmp = new FileStream("c:\\Emp.html", FileMode.Open, FileAccess.Read);
StreamReader srEmp = new StreamReader(fsEmp);
string s;
while ((s = srEmp.ReadLine()) != null)
{
Console.WriteLine(s);
Console.Read();
}
srEmp.Close();
fsEmp.Close();
}

static void writeFile()
{
FileStream fsEmp = new FileStream("c:\\Emp.html", FileMode.Open, FileAccess.Write );
StreamWriter swEmp = new StreamWriter(fsEmp );

string s="Have you seen god? Is there anything else to see";
swEmp.WriteLine(s);
swEmp.Close();
fsEmp.Close();

}


static void Main(string[] args)
{
writeFile();
readFile();
}
}
}
www.codecollege.NET

what are the Differences between Abstract Class and Interface ?




























Sno Abstract
Class
Interface
1 Can have implemented Methods Cant
2 A class can inherit only one abstract class A Class can implement any number of Interfaces.
3 We go for Abstract classes on such situations
where we need to give common functionality for group of related classes
We go for Interface on such situations where we
need to give common functionality for group of un-related classes
4 If you add a new method, then you can provide a
default implementation and so no need to make any change to existing work.
If you add a new method, then you need to change
all the existing work.
5
Static and Instance constants are possible.
Only
Static  constants are possible.


www.codecollege.NET

World No 1 kaspersky Antivirus Free for 6 Months


kaspersky-antivirus2010-get-6-months

LinkWithin

Blog Widget by LinkWithin

Recommended Books