I have a page that is exhibiting the strangest behavior. When building/debugging my project I will sometimes receive build errors pointing to my page directive.
If I insert an additional space between any two attributes in the directive, the error goes away and the build succeeds.
Page Directive:
<%@ Page Language="C#" AutoEventWireup="true" EnableSessionState="true" CodeBehind="myPage.aspx.cs" Inherits="com.mycompany.UserControls.myPage" %>
Resulting Errors:
Keyword, identifier, or string expected after verbatim specifier: @ C:\mypath\myPage.aspx 1 1 myProjectName
A namespace cannot directly contain members such as fields or methods C:\mypath\myPage.aspx 1 1 myProjectName
To reiterate, for example, adding an additional space between Page
and Language="C#"
temporarily clears the errors. I will see a 100% success rate on the next build, but the error will eventually reappear. I can often force the error by closing the editor that is showing the myPage.aspx
and building/rebuilding my project.
Note: This behavior was present in Visual Studio 2008, and still remains after a switch to Visual Studio 2010.
Edit: Corrected typo where @
was omitted from page directive in question.
Any ideas?
You can handle default errors at the application level either by modifying your application's configuration or by adding an Application_Error handler in the Global. asax file of your application. You can handle default errors and HTTP errors by adding a customErrors section to the Web. config file.
Exception handling is an in-built mechanism in . NET Framework to detect and handle run time errors. Exceptions are defined as anomalies that occur during the execution of a program. The . NET Framework provides a rich set of standard exceptions that are used during exceptions handling.
OFF: ASP.NET uses its default error page for both local and remote users in case of an error. ON: Custom error will be enabled for both local as well as remote client. REMOTE ONLY: The custom error page will be shown to a remote user only, the local user will get the built-in error page.
Are you missing the @ symbol between the opening <% and the Page keyword? You have
<% Page Language="C#" AutoEventWireup="true" EnableSessionState="true" CodeBehind="myPage.aspx.cs" Inherits="com.mycompany.UserControls.myPage" %>
and it should be
<%@ Page Language="C#" AutoEventWireup="true" EnableSessionState="true" CodeBehind="myPage.aspx.cs" Inherits="com.mycompany.UserControls.myPage" %>
Your missing @ symbol in your <%@ Page......
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With