WCF – Error 500.21 Handler “svc-Integrated” has a bad module “ManagedPipelineHandler” in its module list”

If you  see this error you havent installed the prerequistes for ASP.NET 4.

Try this

  1. Open Visual Studio Command Prompt
  2. Type the following:
    1. aspnet_regiis.exe -i
  3. Run the command
  4. Try your service again…
  5. Happy Face – it should be working

<system.webServer>
<rewrite>
<rules>
<rule name=”rewrite” stopProcessing=”true”>
<match url=”(.*)” />
<conditions>
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
<add input=”{REQUEST_FILENAME}” pattern=”\.axd” negate=”true” /> <!– for treeview control to render properly –>
</conditions>
<action type=”Rewrite” url=”{R:1}.aspx” />
</rule>
<rule name=”Redirect to clean URL” enabled=”true” stopProcessing=”true”>
<match url=”^([a-z0-9/]+).aspx$” ignoreCase=”true” />
<conditions logicalGrouping=”MatchAll” trackAllCaptures=”false” />
<action type=”Redirect” url=”{R:1}” />
</rule>
</rules>
</rewrite>
</system.webServer>

Sometimeswe will face the issue that the SQL transactions is not committed / rollback,due to this we can’t perform any further operation on the table which are underthe open transaction.

By followingthe below 2 simple steps we can find the open transactions and we can killthem.

DBCC opentran

Thenexecute the below command to kill the open transaction.

KILL server process ID

Example:  KILL 53

function formatAMPM(date) {
  var hours = date.getHours();
  var minutes = date.getMinutes();
   var seconds = date.getSeconds();
  var ampm = hours >= 12 ? 'PM' : 'AM';
  hours = hours % 12;
  hours = hours ? hours : 12; // the hour '0' should be '12'
  minutes = minutes < 10 ? '0'+minutes : minutes;
  var strTime = hours + ':' + minutes + ':' + seconds + ' ' + ampm;
  return strTime;
}
declare @procName varchar(500)
declare cur cursor 

for select [name] from sys.objects where type = 'p'
open cur
fetch next from cur into @procName
while @@fetch_status = 0
begin
    exec('drop procedure ' + @procName)
    fetch next from cur into @procName
end
close cur
deallocate cur

public string draw_calendar(int currentDay, int month, int year)
    {
        /* draw table */
        string calendar = string.Empty;
        calendar += “<div style=’clear:both;’></div>”;
        calendar += ”   <div id=’divCalenderTable’ style=’width: 715px;’>”;
        calendar += “<table cellpadding=’1′ border=’1′ cellspacing=’1′ class=’calendar’>”;

        /* days and weeks vars now … */
        int running_day = 0;
        int days_in_month = DateTime.DaysInMonth(year, month);
        int days_in_this_week = 1;
        int day_counter = 0;
        string[] dates_array = new string[] { };

        /* table headings */
        string[] headings = { “Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday” };
        DateTime now = new DateTime(year, month, 1);
        string strDayName = now.DayOfWeek.ToString();

        calendar += “<tr class=’calendar-row’>”;
        for (int i = 0; i < headings.Length; i++)
        {
            calendar += “<th class=’calendar-day-head’>” + headings[i] + “</th>”;
            if (strDayName.ToString().ToUpper() == headings[i].ToString().ToUpper())
            {
                running_day = i;
            }
        }
        calendar += “</tr>”;

        /* row for week one */
        calendar += “<tr class=’calendar-row’>”;

        /* print “blank” days until the first of the current week */
        for (int x = 0; x < running_day; x++)
        {
            calendar += “<td class=’calendar-day-np’> </td>”;
            days_in_this_week++;
        }

        /* keep going with days…. */
        for (int list_day = 1; list_day <= days_in_month; list_day++)
        {
            calendar += “<td class=’calendar-day shadow’>”;
            /* add in the day number $month,$year */
            int day = 0;
            if (list_day < 10)
            {
                day = 0 + list_day;
            }
            else
            {
                day = list_day;
            }
            string date = day + “-” + month + “-” + year;
            calendar += “<div class=’day-number’ date='” + date + “‘>” + list_day + “</div>”;//
            /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/
            //$calendar+= str_repeat(‘<p> </p>’,2);            
            calendar += “</td>”;
            if (running_day == 6)
            {
                calendar += “</tr>”;
                if ((day_counter + 1) != days_in_month)
                {
                    calendar += “<tr class=’calendar-row’>”;
                }
                running_day = -1;
                days_in_this_week = 0;
            }
            days_in_this_week++; running_day++; day_counter++;
        }

        /* finish the rest of the days in the week */
        if (days_in_this_week < 8)
        {
            for (int x = 1; x <= (8 – days_in_this_week); x++)
            {
                // calendar += “<td class=’calendar-day-np’> </td>”;
            }
        }

        /* final row */
        calendar += “</tr>”;

        /* end the table */
        calendar += “</table>”;
        calendar += “</div>”;
        /* all done, return result */
        return calendar;
    }

 

/********** Calling Function********/

draw_calendar(21, 04, 2014);

Description:-

Here We use Generic Handler Class to Upload Multiple File in database.before we Explain we First understand the what is Generic handler Class.

What is Generic handler Class:-

Generic handler is nothing but a same like aspx page and the extention of this file is .ashx.Generally Generic Handler class are used to Response the Request and Request is Proceed by the page Handler. You can also create your own HTTP Handler and that renders the output to the browser.

In this Example we Provide Facility to user to Browse a Multiple File at a time and Uploading all Browse File at a time with Prgressbar Facility same like provide in GMAIL when we send the Email with Atteched the File. This is simply done with JQuery and we will Requst the Response using Generic Handler.

TriggerUpload.aspx:-

 <%@ Page Language=”C#” AutoEventWireup=”true”  CodeFile=”TriggerUpload.aspx.cs” Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head runat=”server”>
    <title></title>
 <link rel=”Stylesheet” type=”text/css” href=”CSS/uploadify.css” />
 <script type=”text/javascript” src=”scripts/jquery-1.3.2.min.js”></script>
 <script type=”text/javascript” src=”scripts/jquery.uploadify.js”></script>
</head>
<body>
        <form id=”form1″ runat=”server”>
            <a href=”javascript:$(‘#<%=FileUpload1.ClientID%>’).fileUploadStart()”>Start Upload</a>&nbsp;
           |&nbsp;<a href=”javascript:$(‘#<%=FileUpload1.ClientID%>’).fileUploadClearQueue()”>Clear</a>
            <div style = “padding:40px”>
                <asp:FileUpload ID=”FileUpload1″ runat=”server” />
            </div>
        </form>
</body>
</html>
<script type = “text/javascript”>
$(window).load(
    function() {
        $(“#<%=FileUpload1.ClientID%>”).fileUpload({
        ‘uploader’: ‘scripts/uploader.swf’,
        ‘cancelImg’: ‘images/cancel.png’,
        ‘buttonText’: ‘Browse Files’,
        ‘script’: ‘Upload.ashx’,
        ‘folder’: ‘uploads’,
        ‘fileDesc’: ‘Image Files’,
        ‘fileExt’: ‘*.jpg;*.jpeg;*.gif;*.png’,
        ‘multi’: true,
        ‘auto’: false
    });
   }
);
</script>

Upload.ashx:-

 <%@ WebHandler Language=”C#” Class=”Upload” %>

using System;
using System.Web;
using System.IO;

public class Upload : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = “text/plain”;
        context.Response.Expires = -1;
        try
        {
            HttpPostedFile postedFile = context.Request.Files[“Filedata”];
           
            string savepath = “”;
            string tempPath = “”;
            tempPath = System.Configuration.ConfigurationManager.AppSettings[“FolderPath”];
            savepath = context.Server.MapPath(tempPath);
            string filename = postedFile.FileName;
            if (!Directory.Exists(savepath))
                Directory.CreateDirectory(savepath);

            postedFile.SaveAs(savepath + @”\” + filename);
            context.Response.Write(tempPath + “/” + filename);
            context.Response.StatusCode = 200;
        }
        catch (Exception ex)
        {
            context.Response.Write(“Error: ” + ex.Message);
        }
    }

    public bool IsReusable {
        get {
            return false;
        }
    }
}