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;
        }
    }
}

Introduction:
Here I will explain how to upload multiple files with progress bar using JQuery uploadify plugin in asp.net.

Description:

In previous article I explained jQuery lightbox image slideshow, Generate thumbnail from images, Generate thumbnails from YouTube videos using JQuery, jQuery password strength examples and many articles relating to JQuery, asp.net, SQL Server etc. Now I will explain how to upload multiple files in asp.net using uploadify plugin in JQuery.

We can implement this concept by using uploadify plugin with few simple steps for that first create new web application >> Right click on your application >> Select Add New Folder and Give name as UploadFiles.

After completion of folder creation write the following code in your aspx page

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
    <head runat=”server”>
        <title>jQuery Upload multiple files in asp.net</title>
        <script src=”http://code.jquery.com/jquery-1.8.2.js”></script&gt;
        <link href=”uploadify.css” rel=”stylesheet” type=”text/css” />
        <script src=”js/jquery.uploadify.js” type=”text/javascript”></script>
        <script type=”text/javascript”>
            $(function() {
            $(“#file_upload”).uploadify({
            ‘swf’: ‘uploadify.swf’,
            ‘uploader’: ‘Handler.ashx’,
            ‘cancelImg’: ‘cancel.png’,
            ‘buttonText’: ‘Select Files’,
            ‘fileDesc’: ‘Image Files’,
            ‘fileExt’: ‘*.jpg;*.jpeg;*.gif;*.png’,
            ‘multi’: true,
            ‘auto’: true
            });
            })
        </script>
    </head>
    <body>
        <form id=”form1″ runat=”server”>
            <div>
                <asp:FileUpload ID=”file_upload” runat=”server” />
            </div>
        </form>
    </body>
</html>
If you observe above code in header section I added some of css and script files those files you can get it from attached folder or you can get it from here uploadify plugin and if you observe in uploadify function I used Handler.ashx in this we will write the code to upload files in folder for that Right click on your application >> Select Add New Item >> Select Generic Handler file and Give name as Handler.ashx >> Click OK

Open Handler.ashx file and write the following code

C# Code

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

using System.Web;

public class Handler : IHttpHandler {
        public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = “text/plain”;
        HttpPostedFile uploadFiles = context.Request.Files[“Filedata”];
        string pathToSave = HttpContext.Current.Server.MapPath(“~/UploadFiles/”) + uploadFiles.FileName;
        uploadFiles.SaveAs(pathToSave);
    }
    public bool IsReusable {
        get {
            return false;
        }
    }
}

CSS For ASP.NET GridView

Posted: April 3, 2014 in Asp.Net
Tags: , , ,

I use ASP.NET GridView in my projects a lot. It is a great control with powerful functionality that can be customized in many ways. GridView has many settings that you can use to alter its look and also offers you some predefined formats that you can use (you can access them by clicking Auto Format link on the bottom of GridView properties panel). What formats do is to modify different styling properties of the GridView such as row style, alternate row style, header style and so on.

What is the problem?

Modifying different styling properties of the GridView control to create a custom look may be simple but has a few problems. The biggest problem is the styling information will be included in the generated html and that causes the resulting page size to be bigger. Another problem is that you have to modify a lot of properties to find a look that satisfies you. Also later if you want to do a change in the look of GridView you have to modify all instances of the controls in your website.

The Solution

The good news is that you can use CSS to control the look of the GridView easily. You will add a few hooks to the GridView control and you are ready to write some CSS to completely change the look of the control. I have created a sample website to demonstrate this; you can download it from the link below.

Modifying GridView look is very easy using CSS. By spending a little time you can create really cool styles that can reuse in your projects easily. Following picture is a screen shot of the final result of this article.

ASP.NET GridView

Implementation

Here’s the GridView control syntax in our ASP.NET page. The only properties that we need to change to provide the custom look are CssClass, PagerStyle-CssClass and AlternatingRowStyle-CssClass.

  1. <asp:GridView ID=“gvCustomres” runat=“server”  
  2.     DataSourceID=“customresDataSource”   
  3.     AutoGenerateColumns=“False”  
  4.     GridLines=“None”  
  5.     AllowPaging=“true”  
  6.     CssClass=“mGrid”  
  7.     PagerStyle-CssClass=“pgr”  
  8.     AlternatingRowStyle-CssClass=“alt”>  
  9.     <Columns>  
  10.         <asp:BoundField DataField=“CompanyName” HeaderText=“Company Name” />  
  11.         <asp:BoundField DataField=“ContactName” HeaderText=“Contact Name” />  
  12.         <asp:BoundField DataField=“ContactTitle” HeaderText=“Contact Title” />  
  13.         <asp:BoundField DataField=“Address” HeaderText=“Address” />  
  14.         <asp:BoundField DataField=“City” HeaderText=“City” />  
  15.         <asp:BoundField DataField=“Country” HeaderText=“Country” />  
  16.     </Columns>  
  17. </asp:GridView>  
  18. <asp:XmlDataSource ID=“customresDataSource” runat=“server” DataFile=“~/App_Data/data.xml”></asp:XmlDataSource>  

The CSS to provide the custom look is very short and you can change the view and create new looks really easy.

  1. .mGrid {   
  2.     width100%;   
  3.     background-color#fff;   
  4.     margin5px 0 10px 0;   
  5.     bordersolid 1px #525252;   
  6.     border-collapse:collapse;   
  7. }  
  8. .mGrid td {   
  9.     padding2px;   
  10.     bordersolid 1px #c1c1c1;   
  11.     color#717171;   
  12. }  
  13. .mGrid th {   
  14.     padding4px 2px;   
  15.     color#fff;   
  16.     background#424242 url(grd_head.png) repeat-x top;   
  17.     border-leftsolid 1px #525252;   
  18.     font-size0.9em;   
  19. }  
  20. .mGrid .alt { background#fcfcfc url(grd_alt.png) repeat-x top; }  
  21. .mGrid .pgr { background#424242 url(grd_pgr.png) repeat-x top; }  
  22. .mGrid .pgr table { margin5px 0; }  
  23. .mGrid .pgr td {   
  24.     border-width0;   
  25.     padding0 6px;   
  26.     border-leftsolid 1px #666;   
  27.     font-weightbold;   
  28.     color#fff;   
  29.     line-height12px;   
  30.  }     
  31. .mGrid .pgr a { color#666text-decorationnone; }  
  32. .mGrid .pgr a:hover { color#000text-decorationnone; }  

I have used three images for header, alternate rows and pager to create a more appealing look. There images are tiled horizontally using CSS to fit the whole row. You can find the images in the sample website code.

GridView Style Images

Conclusion

Creating custom looks for GridView control is very easy. You can create a completely different look using only a few lines of CSS. You can use the same CSS style for all GridView controls in your project and later if you want to change the look you can do it from one location in your style sheet file.

Hi All,

If you get the error “Error: DNSZone::Table::select() failed: no such row in the table” while choosing the DNS settings from your Plesk control panel(Windows ), you can use the following steps to fix the issue.

1. Login to mysql using the plesk administrator password,

cd %plesk_dir%\Mysql\bin
mysql -u admin -p -P 8306

2. Select the psa database.

use psa;

3. Execute the following sql query in mysql prompt to find those domains that have the wrong zone ids.

SELECT domains.name FROM domains LEFT JOIN dns_zone ON domains.dns_zone_id = dns_zone.id WHERE dns_zone.id IS NULL;

4. Comparing the dns_zone_id in tables ‘domains’ and ‘dns_zone’.

mysql> select dns_zone_id,name from domains;
mysql> select id,name from dns_zone;

5. Manually inserted those missing zone id entries in ‘dns_zone’ table using the insert query statement.

mysql> INSERT INTO dns_zone SET id= zone id, name='domain name';

Change zone id with exact id and name with the exact domain which you want to insert.

That will fix all the issues!