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:
Search This Blog
About Me
My Photo

Full Stack Developer,Blogger,Microsoft Mvp, Mentor, Life long learner, 10+ Years of Experience for JavaScript, web and Microsoft technologies. ASP.NET MVC,Web Forms,C#,AngularJs,Golang
Mvp profile
Subscribe to my blog

Enter your email address:

Follow us on facebook
Blog Archive
Total Pageviews