Saturday, May 4, 2013

Simple data binding with Knockout, Web API and ASP.Net Web Forms

In this post We are going to see How Knockout, ASP.Net Web API and ASP.Net works together smoothly. There are lots many examples of ASP.Net MVC,Web API and Knockout.js available on web working together  nicely. So I thought it will be a good idea to write a blog post about how ASP.Net Web API, ASP.Net Web Forms,Knockout.js works together and how we can create simple data binding with Knockout.js.

ASP.Net Web Forms:


As we all know ASP.Net Web Forms is one of premier development technology widely use in creating web sites and web applications. ASP.Net Web Forms allow to create dynamic websites using event driven model. It is one of the easiest way to create web applications and web sites.


ASP.Net Web API:


ASP.Net Web API is a framework that allows to build HTTP Service that reach a broad range of clients including browsers and mobile devices.It provides very easy way to write restful http services. Its can be access by any type of client over HTTP protocol. Client can make a GET, PUT,POST and DELETE request based on its requirement and get the response appropriately.

Knockout JS:


As per knockoutjs.com, Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. It provides a way to declarative bindings using an ‘Observable’ view model on browser. It supports two way bindings.
Share:
Friday, May 3, 2013

Server.Map alternative in WCF - HostingEnvironment.MapPath

If you are ASP.NET programmer then you already know about Server.MapPath. It is used to map a physical location on webserver for asp.net.  You can find more information about Server.MapPath from the following location.

http://msdn.microsoft.com/en-us/library/ms524632(v=vs.90).aspx

You can still use that in WCF(Windows Communication Foundation) service http bindings. As we know WCF Service can use other non http bindings like TCP/IP,MSMQ and Named Pipe. At that time HttpContext of WCF will be none so server.mappath will not be available as current context is not available. Because its a child class of HttpContext.Current.

HostingEnvironment.MapPath :


HostingEnvironment.MapPath works on all kind of bindings. So when you have other bindings like TCP/IP and MSMQ it will be available as it is inherited from the System.Web.Hosting namespace. You can find more information from below MSDN link.
Share:

Global Windows Azure boot camp 2013–Ahmedabad

Recently before few days Ahmedabad User Group and Microsoft has organized A windows Azure boot camp event on April 27,2013. As an Ahmedabad User Group member I was there and it was amazing event. This post is about to share my experience with Event.
bootcamp_thumbAUGLogo

What is Windows Azure:

Windows azure is a Microsoft Cloud platform. Windows Azure enables you to quickly build, deploy and manage applications across a global network of Microsoft-managed datacenters. You can build applications using any operating system, language or tool. You can fine more information about there from the following links.

http://www.windowsazure.com/en-us/home/features/overview/
Share:
Sunday, April 21, 2013

Server.MapPath variations

Those are working on in web technologies like ASP.Net and ASP are already familiar with server.MapPath method.  It is used to Maps a virtual or relative path to a physical path. Recently I had discussion with my friends what kind of options we have for Server.MapPath and We have discussed lots of things. So I thought it will be a good idea to write a blog post about it. I know this is very basic but sometimes we were not aware about basic things. So following are different kind of options we have with Server.MapPath.
  • Server.MapPath("~") return the root physical path of application.
  • Server.MapPath(“.”) returns the current physical path of a executing file(i.e .aspx file)
  • Server.MapPath(“..”) returns the current physical path of parent directory of executing file.
  • Server.MapPath("/") returns the he physical path to the root of the domain name
It’s very basic so if you try first one. It will load c:\users\lenovo\documents\visual studio 11\Projects\WebApplication1\WebApplication1\

It’s very easy hope you like it. Stay tuned for more.
Share:
Thursday, April 11, 2013

Two free spell checker extension for visual studio 2012 every developer should use

We all are humans and we tends to make mistakes. I am personally take care about lots of spelling mistakes when writing code but sometimes we don’t identify whether there is a spelling mistake there or not. At that time this spell checker extensions come handy.There are plenty of options available for spell checker extensions but In this post I am going to explain those two free spell checker plugins that I am using.

Spell Checker by Noah Richards:


This is a excellent plugin for identifying the spelling mistakes. You can download plugin from following url.

http://visualstudiogallery.msdn.microsoft.com/7c8341f1-ebac-40c8-92c2-476db8d523ce

It’s provides spelling checks for almost all the files.
  1. Plain text files where entire file will be checked for incorrect spelling.
  2. Source code(.cs files)
  3. HTML/ASP files.
For each spelling error, the user is presented with a list of alternative spellings, via a smart tag (activate with ctrl+.), and the option to ignore the word or add it to the user's dictionary.

You can configure the color of the squiggle under misspelled words by changing the foreground color of Spelling Error (in Tools->Options->Environment->Fonts and Colors).  The default color is red. Following is a example for that.

SpellChecker
Share:
Wednesday, April 10, 2013

Why sometimes it’s not a good idea to use session variables in class library project.

As we all know web pages are stateless pages and we need to use session variables in web application to maintain some session over page. Some time we divide our application into multiple layers for example business logic layer,database layer etc. This all layers will be a class library projects.

So when you have your applications divided into the multiple layers at that time you might need to use session variables in the class library projects. For that we are adding System.Web namespace as a reference to a class library project and then we can use session with HttpContext object. That’s works fine if your layers are going to be used in web application projects. But for example if you have service oriented architecture and your services also access your class libraries via non standard protocol i.e. WCF Service hosted on TCP/IP bindings. At that time sessions will not work.

Instead of that you should always use the parameters in method and avoid direct use of session variables. That parameters will passed either from the web application or from the services which is calling the class libraries.

Hope you liked it. Stay tuned for more..
Share:

My feed url changed

Before one year my blog has its own domain name www.dotnetjalps.com and at that time I did not changed the URL of my rss feeds. But now feed burner is providing me a way to change it without effecting my current subscribers so I have changed that to match my domain name.

Following is a new URL for my feeds.
http://feeds.feedburner.com/DotNetJalps

Please note that existing subscribers don’t have to change anything. Only the new subscribers will have that changed now.

Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews