“Asp.net MVC exposed” Lecture Series – Course Outline

Asp.net MVC exposed is a handcrafted lecture series by Ali Sufyan, containing videos, articles, snippets and lots of stuff to guide a new comer to what MVC is, how it works, what is RAZOR framework, multiple API’s working in conjunction with MVC 3, demo apps and lot more. The course outline is as below:


– Introduction to Controllers

– Razor Views

– Data Entity Framework

– Javascript and Ajax

– Implementing Security

– Advance tips and tricks

– Doing wonders

web Page cannot be accessed when hosted in IIS 7

I recently installed windows 7, with IIS 7, being a web developer we need IIS to locally host and test websites. To my surprise, it was not rendering even  a single page, not even html and text files.

First thing that came into my mind was that it is some port blocking issue, but could not seem to know of the software which can block the port 80.

Banging my head here and there, i came to know that it was SKYPE, if skype is installed before IIS, skype uses the freedom to use port 80. So i closed my Skype, and restarted IIS, bang on, it worked like a charm. Hope it helps the guys who get stuck in such scenerio.

Get connection string from the web.config

Pass the method and it will return the connection string for that name (works well if you have multiple connections in the config file) and it will retrieve that specific connection string.

If you fail to provide the name of a connection string it will default to your default (usually 1st in the list) to the default string.

#region GetConnectionstring
/// method to retrieve connection stringed in the web.config file

///Name of the connection /// Need a reference to the System.Configuration Namespace
public string GetConnectionString(string str)
//variable to hold our return value
string conn = string.Empty;
//check if a value was provided
if (!string.IsNullOrEmpty(str))
//name provided so search for that connection
conn = ConfigurationManager.ConnectionStrings[str].ConnectionString;
//name not provided, get the ‘default’ connection
conn = ConfigurationManager.ConnectionStrings[“YourConnName”].ConnectionString;
//return the value
return conn;

XSLT transform in asp with Microsoft.XMLDOM

I recently had to transform an xml file into a scorm manifest file. I wanted it to be in UTF-8, but Microsoft.XMLDOM‘s transform method disregards the encoding setting in xsl:output. The transformNodeToObject method doesn’t. I also found out I had to use the save method on the output object instead of writing a file based on the xml property. You’ll find the function I ended up writing to assist me below:

<script language="javascript" runat="server">
function transformXmlFile(xmlfile, xslfile, outputfile){
    var xml = new ActiveXObject("Microsoft.XMLDOM");
    var xsl = new ActiveXObject("Microsoft.XMLDOM");
    var out = new ActiveXObject("Microsoft.XMLDOM");
    xml.async = false;
    xsl.async = false;
    out.async = false;
    xml.transformNodeToObject(xsl, out);
    xml = null;
    xsl = null;
    out = null;

IE8 aggressive caching fix

Apparently Internet Explorer 8 has a more aggressive caching mechanism than any other browser I’ve ever met. To fix it I’ve added the following to almost every dynamic page on my server.

// prevent caching (asp classic jscript)
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
' prevent caching (asp classic vbscript) '
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
// prevent caching (php)
header('Cache-Control: no-cache');
header('Pragma: no-cache');
header('Expires: ' . gmdate(DATE_RFC1123, time()-1));
// prevent caching (C#)
//Response.AddHeader("Cache-Control", "no-cache");
//Response.AddHeader("Pragma", "no-cache");
//Response.Expires = -1;