FileUpload Error: Object reference not set to an instance of an object

I have come across an error of fileUpload where it kept on saying that the fileUpload.FileName is not set to an instance of an object.

After a lot of debugging and testing I realized that AJAX is limited to update panels. Therefore, make sure you do not place the file upload inside an update panel.

FileUpload requires a FULL POSTBACK!

Error: Cannot use a leading .. to exit above the top directory.

Error: Cannot use a leading .. to exit above the top directory.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Cannot use a leading .. to exit above the top directory.

Solution:

Check The Master page or any Default Page currently using before error appears.

Make sure that references in the <head> </head> section do not go above directory listings.

simple basic example:

If your page is in the main project:

ERROR:         <link href=”../CSS/help.css” rel=”stylesheet” type=”text/css” />

SOLTION:    <link href=”CSS/help.css” rel=”stylesheet” type=”text/css” /> //Removing the ../ 

                        <link href=”<%= ResolveUrl(“~/”) %>CSS/help.css” rel=”stylesheet” type=”text/css” /> //When using ASP.NET we can resolve the URL when not sure about the path

Error: The Controls collection cannot be modified because the control contains code blocks (i.e. )

Error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

SOLUTION:

Search within the <head> </head> part of your page and look for any content with the following characters “<%” or use ctrl+F to look for them.

Make sure you gather all <% parts and place them in a simple PlaceHolder, no matter if they are placed in style tags, script tags or simple html tags.

Example:

<asp:PlaceHolder runat=”server”>

<script type=”text/javascript” src=”<%# ResolveUrl(“~/scripts/jquery.js”)%>“></script>

<script type=”text/javascript”>

function SearchUser() {

document.getElementById(“<%= txt_search.userID%>“).value = “”;

}

</script>

</asp:PlaceHolder>

Error: It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

Error: It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level

Cause: Such error is usually due to a project opened as a Website

Solution: Close Application and open sln (solution file)  or all files as Open Project not Open Website.