5

I've copied over the Web Site files to a new WAP project. Made sure that it compiles and it does. The problem I have is that it can't parse the .aspx pages when I perform a convert to WAP. The error simply says it can't parse the .aspx pages.

When I look at one of the .aspx pages, I have the page directive as such but it can't recognize that namespace. That is the namespace I'm using for my new WAP project.

My code-behind pages all have the namespace Instant.Web as well as the project properties is set to Instant.Web for the primary namespace.

so when I go to a page for example, it's not recognizing the Web.Attachment portion of my Inherits.

Here's an example (slightly modified the wording for privacy):

SomeAspxPage.aspx:

<%@ Page Language="C#" Inherits="Instant.Web.Attachment" Codebehind="SomeAspxPage.aspx.cs" %>
<asp:Content ID="ctlContent" ContentPlaceHolderID="ctlContentPlaceHolder" runat="Server">
    <Frm:Attachment ID="Attachment1" runat="server"/>
</asp:Content>

SomeaspxPage.aspx.cs

namespace Instant.Web
{
    public partial class Attachment : Instant.InstantFrm.Pages.Base.UserPage
    {

    }
}

Also for some reason UserPage in the code-behind isn't showing as a class that you can right-click and go to source. Not sure why because that assembly is definitely in this WAP Project and it's the latest assembly for Instant.InstantFrm

PositiveGuy
  • 46,620
  • 110
  • 305
  • 471

5 Answers5

0

Save and close the solution, then re-open it and try again.

I'm theorizing that VS is caching something and the projects needs to be reloaded.

RubberDuck
  • 11,933
  • 4
  • 50
  • 95
0
  1. Do not know if it is relevant for your real case, but as for your example, you have an attribute Codebehind="Attachment.aspx.cs" which looks for the file Attachment.aspx.cs, but the file's name is SomeaspxPage.aspx.cs. Usually "file could not be parsed" means the wizard cannot find the matching code-behind file and cannot convert the page.

  2. BTW one more note from here:

Before converting the project files, add references to the Web application project for assemblies that existed in the Bin folder to help prevent errors.

It is not clear from your description if you have added the reference to your custom UserPage. If not and that assembly is just copied somewhere into WAP Project it can also cause the converting error.

Kirill
  • 3,028
  • 1
  • 17
  • 18
  • no that's just a posting error. I renamed the page for this thread but forgot to rename it there too. Not an actual code issue, just posting issue here. – PositiveGuy Jul 30 '11 at 02:57
  • I have added references to the bin of the WAP project that are needed so they're already added to that web project. – PositiveGuy Jul 30 '11 at 02:58
  • Just to make it clear: At which point do you experience the problem? You say that at the moment of conversion. But usually the Page in the Web Site project has the attribute CodeFile, and in your example it's already Codebehind (which is being renamed automatically if the conversion succeeds). Have you renamed this attribute manually? And one more thing: Have you tried to name the class the same with the file name, e.g. `Inherits="Instant.Web.Attachment" Codebehind="Attachment.aspx.cs"`? Because I've also had troubles with different names in such a case. – Kirill Jul 30 '11 at 07:50
  • Have you tried to convert a page with codebehind class which inherits from the regular `System.Web.UI.Page`? – Kirill Jul 30 '11 at 07:52
  • If your convert procedure says it cannot parse particular .aspx pages (not all pages in general) you could try [such a solution](http://stackoverflow.com/questions/3922830/convert-to-web-application-error-could-not-parse-aspx-file). – Kirill Jul 30 '11 at 08:17
  • no, the whole point in doing a convert to web app is that since I had copied over all .aspx and .aspx.cs from a web site project into this new WEB project, converting is supposed to create new designer files which is part of the process of making those .aspx WAP based. But I keep getting a parse error when trying to right-click the project OR right click an indivitual .aspx and choose Convert to Web Application. It tells me nothing in the error message WHY it cannot parse the .aspx during the conversion attempt (action). – PositiveGuy Jul 31 '11 at 21:16
  • Take a look at [CodeFileBaseClass](http://msdn.microsoft.com/en-us/library/ydy4x04a.aspx) attribute (not sure it is relevant for your scenario but it is worth checking it). – Kirill Jul 31 '11 at 22:08
  • CodeFileBaseClass would not apply because that's an attribute related to CodeFile, both of which are only for Web Site Projects. WAP uses the Codebehind attribute – PositiveGuy Aug 01 '11 at 02:12
  • Well that's true but since you're still on the web site project side and cannot convert it my idea was that given you're using a custom basepage but are not referencing it in your Page directive it could prevent your web site from conversion to web application. So why not try? – Kirill Aug 01 '11 at 06:40
  • Okay and one more question here. When you go through conversion steps first you create a web app project, then you copy all the files from your web site to the new web app, then you add manually all the necessary references. At this point you would have to try to convert the project via the "Convert to web application" menu option, right? But before you do that, could you try to build the web site and look if there are any other errors except missing .DESIGNER.CS or .DESIGNER.VB files? If there are any, may be you'll find one causing your parsing problem. – Kirill Aug 01 '11 at 06:47
0

Try adding a new blank page to your project, check if that can be parsed.

Then in small steps add functionality until you get the page that is the same as the one that is giving you the error.

This should allow you to identify what the problem is.

Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252
  • looks like the main problem is Warning 126 Unrecognized tag prefix or device filter 'asp'. So for instance it doesn't recognize any – PositiveGuy Jul 30 '11 at 04:29
  • Next thing to check is that asp is enabled in IIS – Shiraz Bhaiji Jul 30 '11 at 05:51
  • didn't matter...none of this. IIS 7 enables .aspx by default. That has nothing to do with why VS can't parse tags. – PositiveGuy Jul 31 '11 at 21:17
  • 1
    Could you check that you have referenced all required dll's. sometimes a project compiles but does not work since you are missing some extension methods. Also check the .net version of the dll's you are referencing. – Shiraz Bhaiji Aug 01 '11 at 06:09
  • yes it's referencing all needed dlls because the entire solution compiles fine. All I did was convert this to VS 2010 and it was a VB.NET project to C#. The references are all there though. – PositiveGuy Aug 14 '11 at 06:52
0

Based on this quote Warning 126 Unrecognized tag prefix or device filter 'asp' in one of the comments, it sounds like you are missing an Assembly reference in your CSProj file.

Verify that you have System.Web in your References folder of the project.

If it is there, verify the version (directory) it is pulling from is the same as what .NET version you are targeting with your project.

s_hewitt
  • 4,252
  • 24
  • 24
  • The entire solution compiles so I'm not missing any dlls. And yes System.Web is there or this thing wouldn't compile anyway. – PositiveGuy Aug 14 '11 at 06:53
-1

For WAP site, I'd remove the ASPX layout completely (except the first line, which is required) and output the content using Response.Write in codebehind. In addition to simplicity, this gives much cleaner output and granular control over the process.

SharpAffair
  • 5,558
  • 13
  • 78
  • 158
  • That doesn't seem it would help here, as the problem is in linking the ASPX and codebehind file together, and your method still requires that. So you completely intertwine your view/presentation/layout with your business logic? That's antithetical to the design of ASP.NET WebForms, MVC, or WebPages. – nekno Aug 02 '11 at 19:09