Posts
what is the difference between declarative and imperative programming
- Get link
- X
- Other Apps
A great C# example of declarative vs. imperative programming is LINQ. With imperative programming, you tell the compiler what you want to happen, step by step. For example, let's start with this collection, and choose the odd numbers: List <int> collection = new List <int> { 1 , 2 , 3 , 4 , 5 }; With imperative programming, we'd step through this, and decide what we want: List <int> results = new List <int> (); foreach ( var num in collection ) { if ( num % 2 != 0 ) results . Add ( num ); } Here, we're saying: Create a result collection Step through each number in the collection Check the number, if it's odd, add it to the results With declarative programming, on the other hand, you write code that describes what you want, but not necessarily how to get it (declare your desired results, but not the step-by-step): var results = collection . Whe...
Difference between WCF and Web service
- Get link
- X
- Other Apps
Difference between WCF and Web service Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service, following table provides detailed difference between them. Features Web Service WCF Hosting It can be hosted in IIS It can be hosted in IIS, windows activation service, Self-hosting, Windows service Programming [WebService] attribute has to be added to the class [ServiceContraact] attribute has to be added to the class Model [WebMethod] attribute represents the method exposed to client [OperationContract] attribute represents the method exposed to client Operation One-way, Request- Response are the different operations supported in web service One-Way, Request-Response, Duplex are different type of operations supported in WCF XML System.Xml.serialization name space is used for serialization System.Runtime.Serialization namespac...
Creating Custom HTML Helpers
- Get link
- X
- Other Apps
Creating custom html code blocks which can be re-used in the entire project. Step1: Add a folder "App_Code" in the root directory. Step2: Add a .cshtml file in the App_Code folder "CustomHelpers.cshml" @helper HomeHelper(){ <h1>Home Page Helper</h1> } Step3: Call the newly added helper code in our existing .cshtml page @{ ViewBag.Title = "Home Page"; Layout = "~/Views/Shared/_Layout.cshtml"; } <h2> Home Page</h2> <div> @CustomHelper.HomeHelper(); </div>
ASP.NET Routing
- Get link
- X
- Other Apps
Introduction In an ASP.NET application that does not use routing, an incoming request for a URL typically maps to a physical file that handles the request, such as an .aspx file. For example, a request for http://server/application/Products.aspx?id=4 maps to a file that is named Products.aspx that contains code and markup for rendering a response to the browser. The Web page uses the query string value of id=4 to determine what type of content to display. In ASP.NET routing, you can define URL patterns that map to request-handler files, but that do not necessarily include the names of those files in the URL. In addition, you can include placeholders in a URL pattern so that variable data can be passed to the request handler without requiring a query string. URL Patterns in MVC Applications URL patterns for routes in MVC applications typically include {controller} and {action} placeholders. When a request is rec...