How do you force Visual Studio 2008 to generate designer.cs e.g. Whatever.aspx.designer.cs - asp.net

I have some webforms in an Asp.Net V2.0 generated using Visual Studio 2005 using Web site technology
Want to import them in to Visual Studio 2008 set to v3.5 (Asp.Net MVC) - where I use Project technology
I'm using Add > Existing Item - Which brings in Whatever.aspx & Whatever.aspx.cs
There is no Whatever.aspx.designer.cs to import
How do you force it to be generated ?

Right-click your aspx file and select Convert to Web Application.

You have to make sure that your project is a Web Application (and not a Website). Then, You can right-click on the file or the project and select "Convert to Web Application". If all goes well, the designer file will be created. If not, then there is a parsing error in the page.
But if you want your project to truly be a MVC application, then you should not be using code-behind files for your webpages (Views), so you need to refactor the codebehind classes into Controllers. See this article why not:
http://stevesmithblog.com/blog/codebehind-files-in-asp-net-mvc-are-evil/

Related

ASP.Net - Missing "aspx.designer.cs" files

We have two ASP.Net projects that we maintain with Visual Studio 2019.
The first project was originally built 10+ years ago and has been upgraded from one Visual Studio version to the next over the years. Everything runs fine.
The second project is a brand new project created with Visual Studio 2019. There are several web forms that we would like to import from the first project to the second project.
The Problem: Those web forms from the first project don't have a "aspx.designer.cs" files - each form only consists of an "aspx" and an "aspx.cs" file. And when they're in that first project everything's fine. They compile and they run fine. If we right-click and go the definition of any of the declarative objects in the "aspx.cs" file a window pops up saying it can't navigate to the symbol - which is fine. Everything works.
BUT... When those web forms are imported to the second project, all of the declarative objects show as being undefined - there's no "aspx.designer.cs" file where they'd normally be defined.
Any thoughts? How can we import and actually use these web forms in the newer project? Do we have to go and manually create that "aspx.designer.cs" file for each web form? There's quite a few of them...
Thanks!
Curt
All these effects are expected. An older/legacy site is represented by the "ASP.NET WebSite" template/structure, while the newer one - the "ASP.NET Web Application".
Check out the following threads to find differences and possible hints for migration (in short - move files as is, correct some #Page directives and code namespaces, switch to the ASPX Design View to re-generate the associated Designer file):
ASP.NET Web Site or ASP.NET Web Application?
Web Application Projects versus Web Site Projects in Visual Studio

ASP.NET Empty Web Site template

I'm trying to find ASP.NET Empty Web Site in Visual Studio 2016 template list, but I can't. It is still exist there or I'm able to use only ASP.NET Web Application?
Open VS2015 > File > New Project > Select ASP.NET web application (.NET framework)
Then press OK to continue. On next template window, select Empty option-
See if this helps.
To create "ASP.NET Web Site" projects in Visual Studio 2016 you need to install the "Additional project templates (previous versions)" ASP.NET Component.
It probably gets missed as this option is only visible if you click on the ASP.NET workload and is not listed on the "Individual components" tab!
See Image 1 here
After installing the component, the templates are now present:
See Image 2 here
Just create an empty folder then "Open Website" option from the startup page.
To create an Empty web site, you need to do the following :
Open VS2015 > File > New Web Site > Visual C# > ASP.Net Empty Web Site

What template to use for new website in Visual Studio 2015?

I'm confused by the myriad of options for creating a new website in Visual Studio 2015.
In particular, I don't understand the difference between
File > New... Website... ASP.NET Website (Razor v3) and
File > New... Project... ASP.NET Web Application > ASP.NET 4.6.1 Templates > MVC 4
What I'd like is a website that works well with Entity Framework and provides scaffolding to quickly create data entry forms.
It seems MVC 4 provides this, but is there something similar for Razor?
The main difference between the Web Application and the Website is that it will compile the application into a single DLL file at build time. In order to update the project it must be recompiled and the DLL file published for changes to occur.
Read more at ASP.NET Web Site or ASP.NET Web Application? and Web Application Projects versus Web Site Projects in Visual Studio

Convert to Web Application in VS 2015.1

I'm running Visual Studio 2015 Enterprise Update 1.
I created an empty Visual Basic ASP.NET Website targeting the .NET Framework 4.5.2. And I want to convert it to an ASP.NET Web Application.
Under the Website's context menu in Solution Explorer there is no "Convert to Web Application" menu-item, nor is there anything under the Website menu in the main-menu bar:
Where has the feature gone? Has it been removed completely in Update 1?
This is the most confusing part of converting websites to web applications. The way you need to do it is to:
Create a new Web Application project
Copy all of your website contents into it (you could create the *.csproj file in the same website directory, then include all files into the project without actually having to move them)
The command will be available on the WebApp project (under the Project menu, at the bottom)
Basically at that point the command looks at the contents of the WebApp project and makes adjustments so that they are more suitable for a WebApp project.

How to get the Silverlight XAP copied to the clientbin on build

I am just getting started with Silverlight and have recently added a Silverlight project to an established solution. In this particular scenario my solution included an existing ASP.NET web site (not application) which Visual Studio kindly offered to integrated my Silverlight application into, which I accepted.
So everything is fine and all, and the Silverlight XAP is being copied to the web site's ClientBin directory. Now I have decided to start a new ASP.NET MVC web application that will eventually replace the older (non-MVC) web site. But I cannot for the life of me figure out what Visual Studio modified to get the XAP to automatically appear in the web site's ClientBin on build, so that I can reproduce that on my MVC site.
So my question is essentially, what are the manually steps for getting Visual Studio to autocopy a Silverlight application's XAP to a newly added ASP.NET MVC web application?
You can do this through the properties of your web project. The Silverlight tools for visual studio add a new tab to the properties of web projects named "Silverlight Links".
Add a reference to your Silverlight project here, with the folder where you want it, and visual studio will make the copy for you.
The copying of the XAP to the ClientBin is a MSBuild task. If you're using a standard ASP.NET project template it can be found under the Silverlight Link section.
For everything else you might be able to figure out the name of the MSBuild task and add it to your ASP.NET MVC project. The easier solution would probably be to use a custom post-build event on the APS.NET project to copy the file.
There is no "magic" happening, oter than copying the XAP file from the BIN directory of your Silverlight project to the ClientBin of your web application. It doesn't even have to live inside the ClientBin directory - you can copy it to any directory, or the root of your site.
Update: The recently released Beta 1 of ASP.NET MVC includes support for Silverlight projects, so you can link it to your ASP.NET MVC application the same way you do for regular ASP.NET applications.
Go to the property pages of your Silverlight application, Choose Build Events Tab, Enter following line in Post-Build events command line:
copy $(TargetDir)*.xap $(SolutionDir)<youar web solution folder name such as app.web>\ClientBin
Now onwards, on each successful build, the xap file will be copied automatically.
This is a somewhat older post so it probably has changed... in my Visual Studio under the web project there is a tab called "Silverlight Applications". There is an add button there for existing projects that you import into the solution and you can add them and choose to place the xap in the ClientBin or anywhere else. Not sure if you have to have the SDK installed to have this tab. I have it installed so you may have to. I don't do MVC, so it may be different for MVC projects, I don't know.

Resources