Tips And Tricks
Wednesday, November 3, 2010
TroubleShoot Windows Blue Screen
http://blogs.msdn.com/b/ndis/archive/2006/10/26/troubleshoot-a-windows-bluescreen-a-k-a-bugcheck-a-k-a-blue-screen-of-death.aspx
Tuesday, May 18, 2010
ASP.NET Form Authentication and HTML Pages
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 Asp.net pipe line.
IIS5 OR IIS6
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
IIS 7
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 asp.net 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
<httphandlers>
< verb="GET,HEAD,POST,DEBUG" path="*.html" type="System.Web.UI.PageHandlerFactory">
</httpHandlers>
In the compilation section add the following
<compilation explicit="true" strict="false" debug="false">
<buildproviders>
<add type="System.Web.Compilation.PageBuildProvider" extension=".html">
</buildproviders>
</compilation>
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
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT 'Show fragmentation for the ' + @TableName + ' table'
DBCC SHOWCONTIG (@TableName)
FETCH NEXT FROM cur_showfragmentation INTO @TableName
END
CLOSE cur_showfragmentation
DEALLOCATE cur_showfragmentation
Tuesday, November 24, 2009
String or StringBuilder to stream/memorystrem
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
go
DBCC SHRINKDATABASE ([Data Base Name], 10, TRUNCATEONLY)
go
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
GO
-- database recovery model
ALTER DATABASE [Database Name]
SET RECOVERY SIMPLE;
GO
-- Shrink log file to 1 MB.
DBCC SHRINKFILE (2, 1)
-- 2 means log file ID or you can specify logfile like DBCC SHRINKFILE (db_log' , 1))
GO
ALTER DATABASE [Database Name]
SET RECOVERY FULL
GO
Thursday, August 20, 2009
WSP Builder Extension Error (System.Workflow.ComponentModel.Compiler.ITypeProvider)
To fix this issue you have to edit your project file :
Goto <project> <propertygroup> :
<projecttypeguids>{F8810EC1-6754-47FC-A15F-DFABD2E3FA90};{D59BE175-2ED0-4C54-BE3D-CDAA9F3214C8};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</projecttypeguids>
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"); - Cheers
- Shyju Mohan
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)