Pages

Search This Blog

Wednesday, September 19, 2007

System.Web.HttpRequestValidationException: A potentially dangerous Request.QueryString value was detected from the client (xx="xxxxx")

Error Message:
System.Web.HttpRequestValidationException: A potentially dangerous Request.QueryString value was detected from the client (xx="xxxxx")


For details discussion on the .Net Request Validation
http://dotnetfish.blogspot.com/2007/08/systemwebhttprequestvalidationexception.html

Causes:
By default, .Net will validate input (Form and QueryString). Input with special tags (HTML, Javascript and etc) will cause the error message shown.


Usage for .NET Request Validation:
This validation can help to prevent "Script Injection".

To turn off the validation: (Not encourage)
<%@Page ... validateRequest="true"%> to <%@Page ... validateRequest="false"%>

Solve the problem:
set ValidateRequest="true" and HTMLEncode the input
For example:
title = Server.HtmlEncode(Request.QueryString["title"].ToString());

Monday, September 3, 2007

Access denied to c:\inetpub\wwwroot\xx. Failed to start monitoring file changes.

When try to run or compile an ASP.NET application, you get error message:
Access denied to 'c:\inetpub\wwwroot\xxxxxx\'. Failed to start monitoring file changes.

This is occur when try to run
  1. a copied version of ASP.NET source code (copy ASP.NET source code from one development machine to another machine)
  2. Folder permission has been reset.
Causes:

Aspnet_wp.exe process identity Or IUSR_(machinename) does not have permissions on one of the directories in the below file path:
  • Web.config files
  • Files in the Bin directory of an ASP.NET application
  • Cache dependency files
Solution:

Grant the required permissions on all of the directories in the ASP.NET process account (ASPNET) and IUSR_(machinename):
Before you start, Please make sure you have turn off Simple File Sharing if you are using windows xp.

  1. In Windows Explorer, browse to the application folder or to the virtual directory that contains the content (for example, c:\inetpub\wwwroot\xx).
  2. Right-click the folder, and then click Properties.
  3. On the Security tab, click Add.
  4. On the "Select Users or Groups" window, click on Advance
  5. Click on Find Now button, you will see List of users
  6. Select ASPNET and IUSR_(machinename) then click OK to close the"Select Users or Groups" window
  7. Allow the following permissions for the ASPNET and IUSR_(machinename) account:
    • Read & Execute
    • List Folder Contents
    • Read
  8. If you want to replace all child object permission with the same permission, Click on Advance and select check box "Replace permission entries on all child objects with entries shown here that apply to child objects" and click OK.
  9. Click OK to close the Properties dialog box and to save the changes.
  10. Restart IIS.

Sunday, September 2, 2007

bitDefender 10 Uninstall Problem

I have installed bitDefender 10 trial version. I found that it consume lot memory from my machine and not able to scan Virus 'myphotos2007.zip'. I have decided to uninstall it. Unfortunately, the process stop have way and display a blue screen. I restart the machine.



I go to Control Panal -> 'Add/Remove Program' and try to uninstall again but bitDefender 10 disappear from 'Add/Remove Program'. I thought it has been remove from my machine but i was wrong. Each time i restart or shut down my machine, above blues screen will be shown. What i try to do is install this trial version again and uninstall it. Sorry to tell, it won't work. Waste my time on doing that.

What can we do to solve it.
Go to
http://www.bitdefender.com/uninstall and download the uninstaller. Click on it to uninstaller it.

Trust me, it will take very long time for the uninstallation and after the process, it will leave your machine a mess.
  1. My wireless not working
  2. Ms Visual studio.net not working
  3. Ms SQL Server Express edition not working
I need to repair both Ms Visual studio.net and Ms SQL Server Express and also need to reset the TCP/IP setting for my wireless connection.

My advice is becareful when try to install bitDefender 10 Trial version.

Handle 'Enter' event in ASP.NET

Problem:

I have two form, search form and login form.

  1. When i keyin username and password and hit enter in Mozilla Firefox. The search form will be trigger.
  2. When i keyin a search key in search key form, validator for login form will be trigger

Form details:

  1. Search form:
    • 1 textbox
    • 1 button
  2. Login form:
    • 2 textbox
    • 2 validator
    • 1 image button

To solve the problem:

  1. Add a panel with defaultbutton for both form.

    <asp:Panel ID="pnlLogin" runat="server" defaultbutton="IbtnLogin">
    <asp:TextBox ID="username" runat="server"></asp:TextBox>
    <asp:TextBox ID="password" runat="server"></asp:TextBox>
    <asp:ImageButton ID="IbtnLogin" runat="server" ImageUrl="~/img/LoginButton.gif" OnClick="IbtnLogin_Click" />
    </asp:Panel>


  2. Set RequiredFieldValidator Enabled = false

    <asp:RequiredFieldValidator ID="vdtUsername" runat="server" ErrorMessage="Enter username" ControlToValidate="username" Enabled="False"></asp:RequiredFieldValidator>
    <asp:RequiredFieldValidator ID="vdtPassword" runat="server" ErrorMessage="Enter password" ControlToValidate="password" Enabled="False"></asp:RequiredFieldValidator>

    Enable the RequiredFieldValidator in IbtnLogin_Click
    IbtnLogin_Click(object sender, ImageClickEventArgs e)
    {
    vdtUsername.Enabled = true;
    vdtPassword.Enabled = true;
    .......................................................
    .......................................................
    .........................................
    }

problem solved!

The type 'xxx' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\xx.v7.2\xx.1063_xx\xx.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\xx.v7.2\xx.61_xx\xx.dll'

I got a error message "The type 'Infragistics.WebUI.Shared.Style' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\Infragistics2.WebUI.Shared.v7.2\7.2.20072.1063__7dd5c3163f2cd0cb\Infragistics2.WebUI.Shared.v7.2.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\Infragistics2.WebUI.Shared.v7.2\7.2.20072.61__7dd5c3163f2cd0cb\Infragistics2.WebUI.Shared.v7.2.dll'" when try to use the bug fixed version for my project, Version 7.2.20072.1063.

To solve the problem:

First, we need to determine which version that i need to use. I need to use Version 7.2.20072.1063.
Second, we need to let out application which Version we need to use by changing web.config. Locate the <assemblies> tag (which should be under <configuration><system.web> <compilation>/<compilers>/<assemblies> ) Between the <assemblies> tag, you should enter something similar to:

<add assembly="AssemblyFileName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB" />

<compilation debug="true">
<assemblies>
<add assembly="Infragistics2.WebUI.UltraWebTab.v7.2, Version=7.2.20072.1063, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
<add assembly="Infragistics2.WebUI.Shared.v7.2, Version=7.2.20072.1063, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
</assemblies>

</compilation>

Problem solved!





To know (GAC) Global Assembly Cache more:

Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache.


Go to Start -> Settings -> Control Panel -> Administrative Tools -> Microsoft .NET Framework 2.0 Configuration

Expand the nodes and locate Assembly cache


We can add new object xxxx here.

To add manually:
Run the .NET command prompt (Start -> Programs -> Microsoft VS.NET -> VS.NET Tools -> VS.NET prompt) and start the gacutil.exe tool with -i parameter (install) and the name of the control, e.g.
gacutil.exe -i "C:\xxx\xxxx.dll"

To remove manually:
To remove xxxx from GAC
Please use the following command: gacutil.exe -u xxxx

We are able to see the different version for the object that we are trying to use. To know more about GAC, please check on
MSDN.