Thursday, February 12, 2015

Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

 

  Today when I was deploying a .NET application in a newly bult server I got an error "Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list".

I was bit surprised to see this error because I was doing a fresh installation on a fresh server. What my suspect was ASP.NET not installed properly on this server. Also that was the error message I was getting when I try to access the URL.

So I ran the below command to re-install the ASP.NET

%windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe -i

You can run this from command prompt or directly in your RUN window which you can open by pressing window button + R

How to validate TextBox inside Gridview using JavaScript

How to validate TextBox inside Gridview using JavaScript

Validating TextBox or any other input control using JavaScript is one of the very common task we do in your ASP.NET application . What if we have to validate the TextBox inside the Gridview using JavaScript? Here we are going to see How to validate the TextBoxes inside the Gridview using JavaScript.
 First we will write the JavaScript to validate the Textbox. This JavaScript will be placed just below the head tag or just above the body tag in your .aspx page.

Below is the simple JavaScript which does Numeric Check.

<script type="text/javascript" language=javascript>
function CheckNumeric()
{
var key;
if(navigator.appName == 'Microsoft Internet Explorer')
key = event.keyCode;
else
key = event.which
if ( !(key >= 48 && key <= 57) && key != 8 && key != 46 && key != 36 && key != 37)
{
event.returnValue = false;
}
}
</script>

Now we will see how to call above JavaScript function. We will call above JavaScript function to check the numeric onkeypress event of the TextBox. If you validate the TextBox onkeypress user will not be able to enter non numeric values.

You will be calling the above function on onkeypress event of the textbox like below.

[code]
//Other Gridview code
...
...
<itemtemplate>
<asp:TextBox id="txtPhone" text='<% # eval("Phone") %>' runat="server" onkeypress="CheckNumeric()"></asp:TextBox>
</itemtemplate>
[/code]
I hope now you are clear about the JavaScript validation on TextBox inside the Gridview

 

How to restrict the user to copy and paste the URL in browser address bar in ASP.NET

How to restrict the user to copy and paste the URL in browser address bar in ASP.NET

 

This is one of the common restrictions you have to apply on a web application. If user is already login to the application and user knows the page extension user can directly copy and paste the URL in web browser to open the page, because user has got already an active session.

In such cases what we have to do is, we will make use of UrlReferrer property.

Please check below code, you may write below code in the page load of each page you wanted to restrict copy and paste of URL to open the page.

string strPreviousPage = "";
 if (Request.UrlReferrer != null)
   {
    strPreviousPage = Request.UrlReferrer.Segments[Request.UrlReferrer.Segments.Length - 1];         
    }       
if(strPreviousPage =="")
    {
      Response.Redirect("~/Login.aspx");
     }

Above code will forcefully redirect to Login page if user copy and paste the URL to open the page.

Also along with this code you might be using your regular authentication code.

Please post your queries if you have any with this code and technique.