开发者

Migrating from ASP.NET 4 website project to web application project in Visual Studio 2010 Causing all controls to throw error?

I recently updated my VS2010 website project from .NET 3.5 to 4.0. Everything was working fine in the website project. Today I decided to migrate the website to a web application project as I have learned this is the best way to work in .NET. I split out all my class files into a separate class library 开发者_StackOverflowand copied all my other content into my new project. Then I updated all the references and web.config.

When I build the class library, everything works great.

The problem is happening when I try to build/debug the web application project. It is acting like all the controls are missing and it is also throwing a bunch of compile errors about the public properties I have in my master pages.

Control errors:

"The name 'INSERT CONTROL NAME HERE' does not exist in the current context"

Master page errors:

'System.Web.UI.MasterPage' does not contain a definition....

It is giving these errors for every single control and master page property in my entire solution.

I notice when I add a new web.form to this project, it also adds a filename.aspx.designer.cs file in addition to the .aspx and .aspx.cs file. My existing files do not have these extra files since they were created in a different .NET version.

Anyone have an idea on how to overcome these issues?

UPDATE: It seems I was missing the step where I need to right click on the new application folder and select "Convert to web application". I just did that and it seems to be a little bit better...

Now it is choking on Literals that are inside single quotes:

<div class='<asp:Literal ID="CssClassLiteral" runat="server"></asp:Literal>'>

It doesn't see this literal when it does the conversion... Is the above valid code or should I implement that functionality another way?


Yes - one of the main differences between the website project and a web application project in Visual Studio is that the web application project defines a designer.cs file for every page/user control.

So, let's say you have a page in a website with a codebehind:

Default.aspx
Default.aspx.cs

In a web application, the designer is now required:

Default.aspx
Default.aspx.designer.cs
Default.aspx.cs

The designer file is auto-generated, but you may need to "touch" each page to generate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜