Posts

Showing posts from August, 2015

What is netNamedPipeBinding in WCF ?

NetNamedPipeBinding is the best mechanism for interprocess communication. With netNamedPipeBinding the security can be achieved only through transport level security as it does not support message level security. However messages are secured as only the same machine can call the service operations. The reason netNamedPipeBinding is the best mechanism because it gives you the default security . NetTcpBinding best when clients are only from intranet. ======= in web.config of service ====== <services> <service name="NorthwindServices.CustomerService" behaviorConfiguration="ServiceBehavior"> <host> <baseAddresses> <add baseAddress="net.pipe://localhost/NorthwindServices/" /> </baseAddresses> </host> <endpoint address="CustomerService" binding="netNamedPipeBinding" contract="NorthwindServices.ICustomer" /> <endpoint address="CustomerService/mex" binding="...

How to manage states in MVC Application ?

For state management we can use viewbag, viewdata, tempdata and session We are using viewbag and viewdata for move the data from Controller to View and if we want move data one action to another action then we use Session and Tempdata

ViewData vs ViewBag

ViewData:- ======== 1. ViewData is a dictionary object that is derived from ViewDataDictionary class. 2. ViewData is a property of ControllerBase class. 3. ViewData is used to pass data from controller to corresponding view. 4. It’s life lies only during the current request. 5. If redirection occurs then it’s value becomes null. 6. It’s required typecasting for getting data and check for null values to avoid error. ViewBag:- ======= 1. ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0. 2. Basically it is a wrapper around the ViewData and also used to pass data from controller to corresponding view. 3.ViewBag is a property of ControllerBase class. 4. It’s life also lies only during the current request. 5. If redirection occurs then it’s value becomes null. 6.It doesn’t required typecasting for getting data

Differences between Class and Structure

1. Classes are Reference types and Structures are Values types. 2. Classes will support an Inheritance whereas Structures won’t. 3. Classes can have explicitly parameterless constructors whereas structures can’t. 4. in structure, you can not declare destructor but in class it is possible. 5. The “this” keyword gives different meaning in structure and class. How? -> In class, “this” keyword is classified as value type of class type within which it is used like inside instance constructor or instance method. -> In structure, “this” keyword is classified as variable type of structure type within which it is used. ====================================================== Why struct doesn't support inheritance ? --------------------------------------- If you want that class should not be inherited in your design, you can use class as sealed. But sealed class can inherit from interface. If you think virtual method cannot to be inherited in derived class at one s...

RAISERROR In SQL Server

Image
SQL Server has its own error handling mechanism, where  @@Error is used to trap the errors and we can get the Error Message for that error.  RAISERROR allows developers to produce our own error message. Using RAISERROR , we can throw our own error message while running our Query or Stored procedure.  RAISERROR is used to return messages back to applications using the same format as a system error or warning message generated by the  SQL Server Database Engine . We can also set our own severity for each and every individual message. To conclude the summary: It allows developers to generate their own messages It returns the same message format that is generated by SQL Server Database Engine We can set our own level of Severity for messages It can be associated with Query and stored procedure General Syntax for using RAISERROR Below is the general syntax for  RAISERROR : Hide     Copy Code RAISERROR ( { Message ID | Message Text } ...

Magic Table in SQL Server

Magic Tables   Magic tables are nothing but the logical tables maintained by SQL server internally. There are two types of Magic tables available in SQL server: Inserted Deleted We can not see or access these tables directly, not even their data-type. The only method to have access to these tables is Triggers operation either After Trigger or Instead of trigger.   Inserting into Table (Inserted Table):   Whenever we do  insert anything in our base table in database, a table gets created automatically by the  SQL server, named as INSERTED. In this table current updated or inserted record will be available. we can access this table of record via triggers.   Updating Table (Inserted & Deleted Table):   Whenever we do any deletion operation on our base table, in spite of one, two tables are created, one is INSERTED and another is called DELETED. Deleted table consist of the current record after the deletion operation...

Stuff Vs. Replace Vs. Substring

Image
Stuff: Using the stuff function we can remove a substring of a certain length of a string and replace it with a new string. Refer the following arguments that we need to pass to the Stuff function: Stuff, Replace and Substring functions in SQL Server First argument passed to the function is the expression. Second argument is the starting length from where the new characters are to be added. Third argument tells how many characters to allocate to the new string being embedded. Fourth argument takes the new string to be embedded as a parameter. 1 2 3 declare @ text varchar ( 50 )    set @ text = 'Welcome to .Net Snippets'    select @ text as Title    Let us run this and check the output. Stuff, Replace and Substring functions in SQL Server We will now add some characters to this string. See the following Stuff function. 1 select STUFF ( @ text , 24 , 3 , '!!' ) as Title It will ...