Troubleshooting Insufficient Disk Space in tempdb

Use this code to get the size of tempdb, free size and check if auto growth is on or not.

 

SELECT SUM(unallocated_extent_page_count) AS [free pages],
(SUM(unallocated_extent_page_count)*1.0/128) AS [free space in MB]
FROM sys.dm_db_file_space_usage;

SELECT
name AS FileName,
size*1.0/128 AS FileSizeinMB,
CASE max_size
WHEN 0 THEN ‘Autogrowth is off.’
WHEN -1 THEN ‘Autogrowth is on.’
ELSE ‘Log file will grow to a maximum size of 2 TB.’
END,
growth AS ‘GrowthValue’,
‘GrowthIncrement’ =
CASE
WHEN growth = 0 THEN ‘Size is fixed and will not grow.’
WHEN growth > 0 AND is_percent_growth = 0
THEN ‘Growth value is in 8-KB pages.’
ELSE ‘Growth value is a percentage.’
END
FROM tempdb.sys.database_files;
GO


MVC3 – 101 Nice Video

http://channel9.msdn.com/Events/DevDays/DevDays-2011-Netherlands/Devdays002

Join Scott Hanselman as he explains ASP.NET MVC from File -> New Project to more advanced topics and ninja tricks!


403.1 and 404 errors in ASP.Net application even if .aspx page exits IIS

IIS Error

IIS Error

You might be able to access all html files and images, but not .aspx pages

This might be one of the reason for this error. Happy coding 🙂


50 Ways to Avoid, Find and Fix ASP.NET Performance Issues

Found this e-book for 50 Ways to Avoid, Find and Fix ASP.NET Performance Issues

Check it out!!!

https://www.simple-talk.com/blogs/2013/01/25/free-ebook-50-ways-to-avoid-find-and-fix-asp-net-performance-issues/


Steps to install the .Net framework 1.1. On Windows Server 2008 R2

  • You can use the Web Platform Installer (Web PI) to easily install IIS, and applications that run on IIS. The Web PI is a free, lightweight tool that lets you install IIS and related technologies such as ASP.NET, SQL Server Express, Visual Web Developer, other popular Web applications, and more. Because the Web PI references and links to the latest versions of available Web Platform offerings, with just a few simple clicks you can download and install any new tools or update.
  • You can also install ASP.NET 2.0 (3.0 and 3.5) using the Windows Vista and Windows 2008 user interface – just install the ASP.NET component located under IIS->Word Wide Web Services->Application Development Features. You can find this set of components in Windows 2008 by clicking Start, and click Server Manager. Expand the left-hand tree view in Server Manager and click Manage Roles, and then Web Server (IIS). In the right-hand pane look for an option that says Add Role Services. If you’re on Windows Vista, click Start, click Control Panel, click Programs, and then Windows Features. Look for the following tree of features under Internet Information Services (IIS):

Untitled1

  • ASP.NET 1.1 is not included in Windows Vista or Windows 2008 and must be downloaded and installed manually. This post shows you how:

STEP 1: INSTALL “IIS METABASE COMPATIBILITY”

The IIS “Metabase compatibility” component is required to successfully install ASP.NET 1.1.

To install it on Windows 2008 Server, click Start, and click Server Manager. Expand the left-hand treeview in Server Manager and click Manage Roles, and then Web Server (IIS). In the right-hand pane look for an option that says Add Role Services. This takes you to wizard where you can install “IIS Metabase Compatibility”.

Untitled2

If you’re on Windows 7, click Start, click Control Panel, click Programs, and then Windows Features. Look for Internet Information Services (IIS) and install “IIS Metabase Compatibility”.

STEP 2: INSTALL THE .NET FRAMEWORK V1.1 AND .NET FRAMEWORK V1.1 SP1

Install Framework v1.1, SP1, and ASP.NET’s security update to SP1:

When you install .NET Framework Version 1.1, and SP1 for .NET Framework Version 1.1, you’ll see the following dialog. Click Run program.

 Untitled3

Note: If you do not install Framework v1.1 SP1, you may run into Data Execution Prevention errors with messages like “IIS Worker Process has stopped working”. This is expected. Installing .NET Framework v1.1 SP1 will fix this.

Untitled4

STEP 3: ENABLE ASP.NET V1.1 ISAPI EXTENSION

Enable ASP.NET v1.1 ISAPI as an allowed ISAPI extension. To do this, open “IIS Manager” administration tool. In the features view, click on the “ISAPI and CGI Restrictions” feature. In the actions pane, click “add”

Extension: C:\Windows\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll
note: change drive if your system drive is not C:\
Description: ASP.NET v1.1

Untitled5
You can also do by running the following command line:

%windir%\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis -enable

STEP 4: ADD IGNORESECTION HANDLER TO V1.1 MACHINE.CONFIG

ASP.NET v1.1 will throw runtime exceptions out of the box if you have IIS configuration in the web.config files that are read by your ASP.NET v1.1 applications. To make ASP.NET v1.1 ignore IIS configuration sections, open the Framework v1.1 machine.config file (%windir%\Microsoft.NET\Framework\v1.1.4322\config\machine.config) and add the following section entry just above the bottom tag for the <configSections> element:

<section name=”system.webServer” type=”System.Configuration.IgnoreSectionHandler,
System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ />
</configSections>

STEP 5: MOVE SITE OR APPLICATION TO ASP.NET 1.1 APPLICATION POOL

During installation, Framework v1.1 creates an application pool called “ASP.NET 1.1” that is configured to load Framework v1.1 upon startup. To move your site or application into this application pool using IIS Manager, please see our online documentation. You can also do this from the command line by navigating to the %windir%\system32\inetsrv directory and running the following command line:

appcmd set app “Default Web Site/” /applicationPool:”ASP.NET 1.1″If you would like to create a new application pool that’s configured to load Framework v1.1, please see our online documentation for creating an application pool. You can also do this from the command line by navigating to the %windir%\system32\inetsrv directory and running the following command line:

appcmd add apppool /name:”NewPool” /managedRuntimeVersion:”v1.1″

Ref: http://technet2.microsoft.com/WindowsServer2008/en/library/ad122434-505b-4fcc-8146-7b21cf10a57f1033.mspx


Export Gird View to excel or Word

Response.Clear();
Response.Buffer = true;
Response.AppendHeader(“Content-disposition”,
“attachment;filename=Report.doc”);
Response.ContentType = “application/msword”;
Response.Charset = “”;
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.AllowPaging = false;
GridView1.DataBind();
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
//Change Color back to white
row.BackColor = System.Drawing.Color.White;
}
GridView1.RenderControl(hw);

//style to format numbers to string
string style = @”<style> .textmode { mso-number-format:\@; } </style>”;
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();


Core Difference…

Core Differences Between IIS and the ASP.NET Development Server (C#)

http://www.asp.net/web-forms/tutorials/deployment/deploying-web-site-projects/core-differences-between-iis-and-the-asp-net-development-server-cs

Nice article


Calculate diff b/w 2 days and get number of business days including hoildays

Summary:

Calculates number of business days taking into account the fillowing

  • weekends (Saturdays and Sundays)
  • US Federal holidays in the middle of the week

public static int BusinessDaysUntil(this DateTime firstDay, DateTime lastDay, params DateTime[] publicHolidays)
{
firstDay = firstDay.Date;
lastDay = lastDay.Date;
if (firstDay > lastDay)
throw new ArgumentException(“Incorrect last day ” + lastDay);

TimeSpan span = lastDay – firstDay;
int businessDays = span.Days + 1;
int fullWeekCount = businessDays / 7;
// find out if there are weekends during the time exceedng the full weeks
if (businessDays > fullWeekCount*7)
{
// we are here to find out if there is a 1-day or 2-days weekend
// in the time interval remaining after subtracting the complete weeks
int firstDayOfWeek = (int) firstDay.DayOfWeek;
int lastDayOfWeek = (int) lastDay.DayOfWeek;
if (lastDayOfWeek < firstDayOfWeek)
lastDayOfWeek += 7;
if (firstDayOfWeek <= 6)
{
if (lastDayOfWeek >= 7)// Both Saturday and Sunday are in the remaining time interval
businessDays -= 2;
else if (lastDayOfWeek >= 6)// Only Saturday is in the remaining time interval
businessDays -= 1;
}
else if (firstDayOfWeek <= 7 && lastDayOfWeek >= 7)// Only Sunday is in the remaining time interval
businessDays -= 1;
}

// subtract the weekends during the full weeks in the interval
businessDays -= fullWeekCount + fullWeekCount;

// subtract the number of bank holidays during the time interval
foreach (DateTime publicHoliday in publicHolidays)
{
DateTime bh = publicHoliday.Date;
if (firstDay <= bh && bh <= lastDay)
–businessDays;
}

return businessDays;
}


Calculate number of Business days b/w two dates – Sql

DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = ‘2011/07/27’
SET @EndDate = ‘2011/07/31’

SELECT
(DATEDIFF(dd, @StartDate, @EndDate) + 1)
-(DATEDIFF(wk, @StartDate, @EndDate) * 2)
-(CASE WHEN DATENAME(dw, @StartDate) = ‘Sunday’ THEN 1 ELSE 0 END)
-(CASE WHEN DATENAME(dw, @EndDate) = ‘Saturday’ THEN 1 ELSE 0 END)


ASP.NET Session Timeout Alert by Jason Heine

Link to latest jquery in head section

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<style type="text/css">
        .message
        {
            border: 1px solid #CCCCCC;
            position: absolute;
            width: 400px;
            border: 1px solid #c93;
            background: #ffc;
            padding: 5px;
            left: 0px;
            top: -170px;
        }
    </style>
<script language="javascript" type="text/javascript">
         function ShowAlert() {
             //get the height and width of the screen
             var windowWidth = document.documentElement.clientWidth;
             var windowHeight = document.documentElement.clientHeight;

             //get the height and width of the message box
             var popupHeight = $("#TimeoutMessage").height();
             var popupWidth = $("#TimeoutMessage").width();

             //show the message box
             $("#TimeoutMessage").animate({
                 "top": windowHeight / 2 - popupHeight / 2,
                 "left": windowWidth / 2 - popupWidth / 2
             }, 1000);

             //close the message box when cross red image is clicked
             $("#close_message").click(function () {
                 $("#TimeoutMessage").fadeOut("slow");
             });

             setTimeout('Redirect()', 900000); //15 minutes in milliseconds
         }

         function Redirect() {
             window.location = "/Pages/Logon/Logout.aspx";
         }

    </script>
<script language="javascript" type="text/javascript">
        $(document).ready(function () {
            setTimeout('ShowAlert()', <%=((Session.Timeout * 60) * 1000) - 900000 %>);
        });
    </script>

Code to to show pop-up message

<div id="TimeoutMessage" class="message">

        <p>
            You will be logged out due to inactivity in 15 minutes.<br /><br />
            Please refresh this page, or click on an action to refresh your session.</p>
    </div>
Ideally this code should be either in the master page or an user control (header or footer)

Ref: http://jasonheine.com/2011/01/14/asp-net-session-timeout-alert/

Avinash Kalakonda's Blog

Keeping productivity simple