Saturday, December 11, 2010

OAuth

 OAuth an open protocol to allow secure API authorization in a simple and standard method from desktop and web applications.

 Almost all Social networks  provide a method to share there data  with data with others by the method of OAuth. By this Authorization  for example if i am integrating Twitter with my website the user dosen't need to provide the uname/password of him in my site but they can authenticate in twitter itself and he can give allow permission so that he can view his Tweets and post of others and can Tweet from mysite to Twitter...
This is a  good technology as OpenID. very very Secure.

I have implemented it already for Picassa,Twitter,Facebook and Youtube. for example u can check this site in development stage.

http://208.109.209.105:1081/phaseoflife/

Monday, August 2, 2010

Prevent Pages from going to history on Back Button click using Javascript

Hi we can prevent the  pages ability to go back by using java script. Suppose From Default.aspx page we go to Default2.aspx and we dont want to go to default.aspx from default2.aspx. for this we can place make place javascript on  default.aspx.
 

Saturday, July 31, 2010

ViewState and Hacking ViewState Data In ASP.NET Beware!!!!!!!!

Asp.net View State help us to retrieve data after Postbacks. But  remember this data is generally not safe as it is simply serialized  and stored in the rendered HTML.

 Suppose  this is the Server Code

Wednesday, July 28, 2010

URL Mapping in ASP.NET

In an ideal world, we'd design our Web applications perfectly the first time. Pages would be created in the proper folder and stay there. For that matter, end users would never care about the URLs of the pages in our Web applications, so we could put pages anywhere we wanted without worrying about it.

Get Number of mysql connections if Connection are not cached

string  Qry=" FLUSH STATUS ;SHOW GLOBAL STATUS LIKE '%Max_used_connections%' ";
MysqlDataAdapter ad =new MysqlDataAdapter(Qry);
so fill that to dataset and u will get that.

If connection is cached u need to do work on thread cache and work on  that.

Send Email in Asp.net .. System.Web.Mail

 We can easily sent emails from asp.net using Mail Message which comes under name-space System.Web.Mail.

The Code is as Follows...

Monday, July 26, 2010

C# code Protection Using .NET REACTOR

The assembly (.exe, .dll) etc we build using .Net Framework  can be decombiled using visual studio command Promt.  ildasm is the commad that we can use to open an assembly as Resource hacker is doing.

C:\Program Files\Microsoft Visual Studio 9.0\VC>ildasm

Saturday, July 24, 2010

Xml Creation and Reading that to DataSet

 Creating XML and Reading that is  very important when we come to Web-service, Serialization etc
Here i just give the basics of  creating and reading xml.

Friday, July 23, 2010

ASP.NET Viewstate MAC failed Error ... What is this?

    “Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.”

Monday, July 19, 2010

CAPTCHA generation in asp.net c#

CAPTCHA stands for "completely automated public Turing test to tell computers and humans apart." What it means is, a program that can tell humans from machines using some type of generated test. A test most people can easily pass but a computer program cannot. Mainly intended to reduce spam on our websites.

Sunday, July 18, 2010

CSV generator for asp.net c# without writing file in server...

Last topic (http://martinkabraham.blogspot.com/2010/07/csv-generator-for-aspnet-c.html) we see generating csv by saving that csv file to server folder that  need to set folder permissions (chmod(7,7,7)). Now lets see to generate csv without writing that to server.
Encoding.ASCII.GetBytes(CompleteCsv) will givbe the bye[] for the  Respose object to binary write.

Saturday, July 17, 2010

ASP .net PAGE CACHING and Substitution Control

Here we can have some basics about asp.net page caching. Think about a situations in which we are paging lakhs of data  in this case response each times goes to server and if the users are large in number that site goes to stuck definitely. It is worth to note that every post backed pages are in server memory and which are eating  server memory.  To over come this we use cache in asp.net pages.

Cache can be on same server or on another server. Cache have a duration and server will handle the post back only after the cache is expired. Till the page is in cache post back are not handled by the server.

Friday, July 16, 2010

CSV generator for asp.net c#

 The term csv stands for Comma Seperated values, means each value is seperated by simply a  comma.
eg:martin,sobin,alex

 The importance of csv is that it can open in excel,Open-office etc. so if we want to export some db data to excel .. the coder can export that to csv so the user can best fit that on Excel or  Open-office

This code will help you to generate csv from a dynamically created datable....
This example pull  download window to download csv file and save that to local machine.

Saturday, July 3, 2010

Skin Files in Asp.net ( App_Themes) Easily apply style to Server Controls

To Customize server Controls , ie having different background image,fore-color,bold etc  it is hard to go to each control and set its properties or css class. Asp.net provide an easy way to manage this. By use if Skin files we are able to manage that.

Website->AddNewItem->SkinFile

Skin file will be added to the Project.Vs will automatically add that to App_Themes->SkinFiles->skin.skin.
To bring that skin file to our page go to Source view and  add

Friday, June 25, 2010

How to Effectively Validate ASP.NET Page...when Javascript disabled in Browser ( When Validation controls become useless)

Consider a situation Like this .....
asp:TextBox ID="USERNAME" runat="server" asp:TextBox

asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server"
ErrorMessage="USER NAME CANNOT BE BLANK" ControlToValidate="USERNAME">asp:RequiredFieldValidator

asp:Button ID="submit" runat="server" Text="SUbmit" onclick="submit_Click"

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

protected void submit_Click(object sender, EventArgs e)
{
Response.Write("I am fired.........!!!");

}


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Since we have the required field validator over there "submit_Click " works only when it is not blank...



Try to disable JavaScript on your Browser and press button. You can see Post back happen also the validator message comes but the code goes to execution by printing "I am fired.........!!!" ... So a hacker can easily destroy your validation my disabling java script in browser...


So my Friends go for this code in Button Click

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

protected void submit_Click(object sender, EventArgs e)
{

if (Page.IsValid)
{
Response.Write("I am fired.........!!!");
}

}


The intelligent .net checks this in Server side. So code will execute only if page.Isvalid=true.....





Thanks for using System.Web.UI


:)

Monday, April 26, 2010

Delete asp.net Listbox item...(Multiple Items) !!

 Suppose  ListBox1 be the list box with some items in it we can delete the selected items in the Listbox with the below code..

for Multiple selection, enable the Multiple option of the List box to "Multiple"..


        for (int i = 0; i < ListBox1.Items.Count; i++)
        {
            int myindx = ListBox1.SelectedIndex;
            if (myindx >= 0)
            {
                if (ListBox1.Items[myindx].Selected == true)
                {
                    ListBox1.Items.RemoveAt(myindx);

                }
            }
        }

Asp.net List box to ListBox Transfer....

   
The ListBox control enables you to display a list of items to the user that the user can select by clicking. A ListBox control can provide single or multiple selections using the SelectionMode property. This tutorial show you how to choose multi items and move them to the other Listbox.


The ListBox control enables you to display a list of items to the user that the user can select by clicking. A ListBox control can provide single or multiple selections using the SelectionMode property. The ListBox also provides the MultiColumn property to enable the display of items in columns instead of a straight vertical list of items. This allows the control to display more visible items and prevents the need for the user to scroll to an item. This tutorial show you how to move items of ListBox from one to the other.

Thursday, April 22, 2010

POP3 (Post Office Protocol) in Asp.net to recieve email

Hi all .. let me Put Some begginging to read email from gmail using POP3.. all the details of your mail server can be get from gmail settings...
Socket programming enable us in doing this ... lets see that in simple

Sunday, April 18, 2010

Developing on MONO !! its Great!!!!!!!!!!

HI all............

Think about the situation in which we are able to run c# code on Mac and Linux Machines..
Its real now.. We can convert our software developed in C# to run on Linux and Mac Machines..
Me started it too.. and the MONO can help us in doing that.. :)


Mono and .NET compile source code into 'assemblies'. Assemblies, which are similar to collections of Java .class files, contain language-independent, platform-independent bytecode called CIL (Common Intermediate Language). Because assemblies are language independent, it doesn't matter what language was used to create them. Assemblies made with C# can mix with assemblies created with VB.NET, Java (using IKVM), or any language that someone has written a CIL compiler for.

But, being platform independent means, of course, that assemblies need to be compiled again into native code before they can run on any particular machine. It's important to distinguish the two compilations involved in Mono applications: from source code to byte code, and from byte code to native machine code. The first compilation is performed by the developer. The second compilation is generally performed just when the program begins executing, on the very computer that will run the application, and for this reason it's called Just-In-Time (JIT) compilation. This second compilation and the execution of the application is performed by a Common Language Runtime (CLR).

Mono also supports Ahead-Of-Time (AOT) compilation. This is a mode that pre-compiled the code, and it is useful to reduce application startup time (by eliminating the JIT startup time) and increasing the code that can be shared across multiple applications.

On Windows and Linux, as well as other operating systems, assemblies are stored in files with the .dll or .exe extension. The only difference between a .dll assembly and a .exe assembly is that a .exe assembly contains a starting point for an application (a Main method), whereas .dll assemblies only are class libraries

Tuesday, January 5, 2010

Admin is not Admin in WIndows Vista !!


The directory access and Write permision using code in Vista is in blocked state. so Project working in Xp will do HELL in vista throwing access exceptions.....

to over come this add manifest file from project add new item and precombile it thus Avoid that Vista Hell....
So that we are able to pull the Vista UAC .............

Monday, January 4, 2010

create fullcontrol to a directory for windows machines

System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);
System.Security.Principal.NTAccount acct = sid.Translate(typeof(System.Security.Principal.NTAccount)) as System.Security.Principal.NTAccount;
string strEveryoneAccount = acct.ToString();



DirectoryInfo dInfo = new DirectoryInfo(Environment.CurrentDirectory + "\\serverservice");
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(strEveryoneAccount, FileSystemRights.FullControl, AccessControlType.Allow));

dInfo.SetAccessControl(dSecurity);