Wednesday, November 3, 2010

TroubleShoot Windows Blue Screen

As a windows user we all probable seen the windows blue screen N number of times.It also sometimes restart automatically without saying anything. Normally we end up in Repairing or reinstalling the OS.If your Tech Savy you could try to find out which causing the issue for your OS.It might be related to a driver you installed.If you are intrested more read this nice article which will give you some input in troubleshooting OS issues with WINDBG.

Tuesday, May 18, 2010

ASP.NET Form Authentication and HTML Pages

This blog help you to understand the applicability form authentication.We can say authentication is two step process
IIS Authentication : IIS authenticates the user and creates a Windows token to represent the user. IIS determines the authentication mode that it should use for a particular application by looking at IIS metabase settings. If IIS is configured to use anonymous authentication, a token for the IUSR_MACHINE account is generated and used to represent the anonymous user. IIS-then passes the token to ASP.NET Pipe Line
ASP.NET Authentication
The authentication method used is specified by the mode attribute of the authentication element. The following authentication configuration specifies that ASP.NET uses the FormsAuthenticationModule class:

You can lean more about this on MSDN click here or in Microsoft Pattern & Practices clik here

Once you have form authentication is set for a specific web site does it helps for html and other multimedia files ? Good question ? Let see how to protect html pages.
Form Authentication for html pages
we knows that authentication has two parts , so we need to make sure that html request should go through ASP.NET pipeline.So we have to tell IIS that all these extensions should be processd through pipe line.

a.) right click on your virtual directory --> properties
b.) find the virtual directories tab for IIS 5.0 or the Home directories tab for IIS 6.0 and click "Configuration"
c.) find the .aspx extension, double click, and copy the path to aspnet_isapi.dll, the path being found in the executable text area
d.) click "add" under the "application configuration" window and paste the path to aspnet_isapi.dll inf the executable text area
f.) type ".htm" (without the quotes) in the extension text area (this can be replace with any file extension eg: asp/html)
e.) while still in the "add/edit application extension mapping" window click the "limit to" radio button and type "GET,HEAD,POST,DEBUG"
f.) ensure that the "script engine" radio button is selected but not the "verify the file exists" radio button

a, Go to you site in IIS
b, Under IIS section click on Handler Mapping (It will open mapping List)
c, Select asmx Mapping and click on Edit.
d, In Request path add html (*.aspx,*.html)
e, Click on Request restriction button and make sure the settings as said above iis5 or iis6

Now we can route all the html pages throug ASP.NET pipeline.Now we let the IIS to know how the html pages should be processed , so next step is to tell ASP.NET how to process these files.How we can do that any guess ? , For all application all these process information are in the web.config file so lets update the web.config file.Basically we need to specify the httphandler.

Add the following entry to Httphandler in system.web section web.config file
< verb="GET,HEAD,POST,DEBUG" path="*.html" type="System.Web.UI.PageHandlerFactory">
In the compilation section add the following
<compilation explicit="true" strict="false" debug="false">
<add type="System.Web.Compilation.PageBuildProvider" extension=".html">

Now its ready to go.Hope this will help in understanding form authentication implimentation for html pages.

Wednesday, March 10, 2010

Fragmentation details in all tables

DECLARE @TableName sysname
DECLARE cur_showfragmentation CURSOR FOR
SELECT table_name FROM information_schema.tables WHERE table_type = 'base table'
OPEN cur_showfragmentation
FETCH NEXT FROM cur_showfragmentation INTO @TableName
SELECT 'Show fragmentation for the ' + @TableName + ' table'
FETCH NEXT FROM cur_showfragmentation INTO @TableName
CLOSE cur_showfragmentation
DEALLOCATE cur_showfragmentation

Tuesday, November 24, 2009

String or StringBuilder to stream/memorystrem

string myString = sb.ToString();
byte[] myByteArray = System.Text.Encoding.UTF8.GetBytes(myString);
MemoryStream ms = new MemoryStream(myByteArray);

Thursday, November 19, 2009

Shrinking SQL Server Database and Transaction Log

I was spending time on shrinking the transaction log and DB, some of our developer boxes didnt have enough space.After a while i just figured so i thought of sharing with others

backup log [DataBase Name] with truncate_only --Not supported in 2008

SQL Server 2008 use different approach because its no longer supports backup log with truncate_only

In SQL Server 2008 , Transaction can be shrinked in two step.

Set Recovery Model to Simple

Shrink the file using DBCC ShrinkFile


-- database recovery model

ALTER DATABASE [Database Name]



-- Shrink log file to 1 MB.


-- 2 means log file ID or you can specify logfile like DBCC SHRINKFILE (db_log' , 1))


ALTER DATABASE [Database Name]



Thursday, August 20, 2009

WSP Builder Extension Error (System.Workflow.ComponentModel.Compiler.ITypeProvider)

Solving the error :The service 'System.Workflow.ComponentModel.Compiler.ITypeProvider' must be installed for this operation to succeed. Please ensure that this service is available.
To fix this issue you have to edit your project file :
Goto <project> <propertygroup> :
For VB Project <Project :
<import project="$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.5\Workflow.VisualBasic.Targets">

Wednesday, August 19, 2009

How to Load an assembly from a file and call the metods of a class

  • Step 1: Add the reflection namspace
    using System.Reflection;

    Step 2: Load the assembly from the file
    Assembly testAsm = Assembly.LoadFrom(@"C:\AddList.dll");

  • Creates the assembly object by calling LoadFrom method in the assembly class and pass the path of the assembly as a parameter.

    Step 3 :Create the type object
    Type testType = testAsm.GetType("Blog.Sample.ListCreator");

    Call the GetType function of the assembly class to create the Type.In above example there is a namspace called Blog.Sample and class called ListCreator.

    Step 4:Create the instance of the Class
    object testObj = Activator.CreateInstance(testType);

    Use Activator.CreateInstance method to create the instance of the required class by passing the Type object which we created in the above step.

    Step 5: Call the method
    testType.InvokeMember("CreatList", BindingFlags.Default BindingFlags.InvokeMethod, null, testObj, new object[] { "BlogSample", "AssemblyBlog" });

    Use the Type.InvokeMember to call the method in the class of loaded assembly.

    Parameter Details:
    1, Name of the Method (Ex: "CreateList")
    2, Binding Flag(We are invoking a method so it will be BindingFlags.InvokeMethod)
    3, Binding object - you can pass null
    4, Target Object - which class's method need to be called (Object which is created by Activator.Creatinstance method - instance of the class)
    5, Object Array of parameters for method (Above passed two string parameters)
  • Cheers
  • Shyju Mohan