Friday, July 18, 2014

HTTP Error 404.13 - Not Found : The request filtering module is configured to deny a request that exceeds the request content length

Configuring via IISManager

Open the IIS Manager and select the site or application you need to configure in the left panel

Select "Features View" and double click on the "Request Filtering" icon.

 

Figure : Request Filtering

Note :

If you can't find the "Request Filtering"icon, you need to install the IIS Administration Pack from this link : http://www.iis.net/download/AdministrationPack. This is a lightweight installation which shouldn't take too much time on a decent internet speed.

Double clicking on the "Request Filtering"icon will bring up the Request filtering configuration window. Right click on the window and select the "Edit Feature Settings" option:

 

Figure : Edit Feature Settings option in IIS

Finally, specify the Maximum allowable content length (In Byte) in the following window and click "OK" to save:

 

Figure : Specifying Maximum allowable content length in Bytes

This worked perfect for me and I was able to upload the large file now without any problem. Hope, this will work for you too :)

Tuesday, July 15, 2014

SQL SERVER – How to Allow Only Alphabets in Column – Create Check Constraint to Insert Only Alphabets


user can create a check constraint over column to allow insertion of alphabets in the column. Here is a sample script where I demonstrate how users can create constraint over column first so it only allows alphabets.

USE tempdb
GO
-- Create Test tableCREATE TABLE TestTable(ID INT, FirstCol VARCHAR(100),CONSTRAINT FirstCol CHECK (FirstCol NOT LIKE '%[^A-Z]%'))GO-- This will be successfulINSERT INTO TestTable (ID, FirstCol)VALUES (1, 'SQLAuthority')GO-- This will throw an errorINSERT INTO TestTable (ID, FirstCol)VALUES (1, 'SQLAuthority 1')GO-- Clean upDROP TABLE TestTable
GO

Monday, July 14, 2014

get the Computer's Unique ID asp.net

string cpuInfo = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();

foreach (ManagementObject mo in moc)
{
     if (cpuInfo == "")
     {
          //Get only the first CPU's ID
          cpuInfo = mo.Properties["processorID"].Value.ToString();
          break;
     }
}
return cpuInfo;

Tuesday, July 8, 2014

Problem using context in global.asax file asp.net iis7

 <%@ Application CodeBehind="Global.asax.cs" Language="C#" %>

<script RunAt="server">
    public void Application_Start()
    {
        string str = Context.Request.Url.AbsoluteUri.Replace("http", "https");
        Context.RewritePath(str);
    }
</script>
Error will like this:
"Request is not available in this context"
 Now Just modify code like bellow in Global.asax
 
The main reason is that the RewritePath is not working because the http and https are working on different port. Also the Application Start is not the place to call this thinks. The BeginRequest is the one. 
protected void Application_BeginRequest(Object sender, EventArgs e)
{
    HttpApplication app = (HttpApplication)sender;
    string cTheFile = HttpContext.Current.Request.Path;
    string sExtentionOfThisFile = System.IO.Path.GetExtension(cTheFile);
    if (sExtentionOfThisFile.Equals(".aspx", StringComparison.InvariantCultureIgnoreCase))
    {
        if (!app.Context.Request.IsSecureConnection)
        {
            Response.Redirect(app.Context.Request.RawUrl.Replace("http://", "https://"), true);
            return;
        }
    }

    // rest of your code here and below
} 
 
it's working 100%.. 
 

Opps Part 1 : Abstraction

  Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...