Search This Blog

Tuesday, September 20, 2016

What is AntiforgeryToken() in MVC

Generates a hidden form field (anti-forgery token) that is validated when the form is submitted.

The anti-forgery token can be used to help protect your application against cross-site request forgery(CSRF).

Cross Site Request forgery is a type of a hack where the hacker exploits the trust of a website on the user. In other words, the site trusts the user (because they have authenticated themselves) and accepts data that turns out to be malicious.

CSRF attack depends on the fact that the site trusts the user’s input. From here on the hacker attempts to get authenticated users to click on links that submit data without the user actually realizing. For example, say you are logged on to your bank that has the ability to transfer money from one account to another. The hacker somehow reverse engineers this form and sets up a duplicate form that submits transfer requests to their own account. (This is an overly simplistic scenario because most banks require you to register and ‘Transfer Account’ as a separate step). 

To use this feature, call the AntiForgeryToken method from a form and add the ValidateAntiForgeryTokenAttribute attribute to the action method that you want to protect.

Wednesday, February 6, 2013

Could not allocate a new page for database 'TEMPDB' because of insufficient disk space in filegroup 'DEFAULT'. Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup

Right click on database name, go to Properties.Go to files and see auto growth column and click on ... button and check enabled auto growth and checked unrestricted option and get solved the error.


Thursday, January 24, 2013

How to serialize object to Json string

Crate Object and use JavascriptSerializer to Convert your object to Json string.
Example is as below.

Import assembly System.Web.Script.Serialization to your page.

JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
string jsonstring = jsonSerializer.Serialize(yourObject);

Monday, August 8, 2011

What is Serialization?

Seralize : -
                 The process of Converting object into a stream of bytes. This stream of bytes can be persisted. Deseralization is the reverse process. It is converting stream of bytes into object.

Seralization is generally used during remoting while transporting objects and to persist file objects and database objects.

In .net 2 ways of seralization is there : 1) XMLSerializer and 2) BinaryFormatter / SoapFormatter

Friday, June 10, 2011

SubSonic

SubSonic is a data-layer builder. More than that, it's an auto-magic object-relational mapping (ORM) tool.

 SubSonic reads the structure of your database, and builds classes to provide you with a fast and flexible data access layer. It requires minimal configuration to set up, provides you with a number of different methods for retrieving and saving data, and includes methods to customize the classes  

Once you have created your DAL with SubSonic, either manually or using the build provider, you are ready to begin to query your database. At this writing, there are providers for a number of databases:

    Microsoft SQL Server 2000 or 2005, including Express
    MySQL
    Oracle
Compared with other ORMs, SubSonic requires remarkably little configuration. At a minimum, you will need to add the following to your web.config (or app.config) file:
  • One or more connection string
  • The SubSonic section handler
  • A link between the appropriate connection string(s) and the SubSonic classes

SubSonic generates three classes for each table in your database:
  •  A singular version of the table name. For example, if you have the table Products, the class will be named Product. This is a strongly-typed class representing a single row in the table. Each column in the table will be represented by a strongly-typed property of the class. Fields that accept null values are defined as nullable.   
  • A controller (e.g. ProductController). This provides the basic CRUD (Create, Retrieve, Update and Delete) functionality. You can use the Controller class as the data source for your page using the ObjectDataSource control.





Friday, October 22, 2010

How to override web.config for subfolder?

If you have website and there might be subfolder that also contains website then there might be also web.config.

When you try to run subfolder site it creates problem related connectionstring if connectionstring is with the same name.


So you just have to add tag in both web.config so your both website running well.

Thursday, October 14, 2010

what is Json ?

JSON is a java script Object Notification, is a lightweight Data-interchange format. Its easy for human read and write. Easy for machine to parse and generate. It is free from language but uses conventions that are familiar to programmer of C,C#,Java etc..

Json Built on two structures :

1.  A collection of name/value pairs called object, record, struct, key list, hash table in language terms.
2.  An ordered list of values called array, vector, list in language terms.

These are the universal data structures. Virtually all languages supports these structure in one form to another.

In Json following form is used:

    1. An object is an unordered set of name/value pairs. which starts with { and ends with } and each name is followed by : and the name/value pair is separated by comma.
    2. An array is an ordered set of values, which starts with [ and ends with ] and each value is separated by comma.
    3. A value can be string, int, struct, array, object and these structures can be nested.
    4. A string is a collection of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.