ASP.NET MVC - compiler not updating global.asax - asp.net

I was trying to make some changes to my global.asax.cs file, when I spotted, that after publishing my mvc application that file is not even touched by visual studio. Last modified date is from last week, while today I made a lot of changes to it. How do I force visual studio to actually do something useful?

Make sure that the "Build Action" for the Global.asax is set to "Content". Open Visual Studio -> Right Click on Global.asax -> Build Action

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

Intellisense for WebForms doesn't work in Visual Studio 2019

I use Visual Studio 2019 (16.7.7). I created new ASP.NET Web Application (.NET Framework) with web forms. But in code behind “Find All References” doesn’t work for setter. And in .aspx-file I can’t “drill down” to user control definition. It seems like a plain text.
I can’t use a previous visual studio version. My current project contains a lot of web forms and also projects with PackageReference format
I had installed visual studio 2017 before. But I unistalled it according to https://learn.microsoft.com/en-us/visualstudio/install/uninstall-visual-studio?view=vs-2017 and https://learn.microsoft.com/en-us/visualstudio/install/remove-visual-studio?view=vs-2017 Also I several times have reinstalled visual studio 2019 but problem remains
Here are steps to reproduce:
Create ASP.NET WEB Application (.Net Framework) C#
Select Web Forms Template
At ViewSwitcher.aspx.cs file I have added public property
public string SomeProp { get; set; }
At Site.Mobile.Master file I have added value. Here intellisense works. It suggests property SomeProp.
<friendlyUrls:ViewSwitcher SomeProp="someValue" runat="server" />
Build.
Return to ViewSwitcher.aspx.cs. I do right mouse click on set of SomeProp and click "Find All References". But it doesn't show using from Site.Mobile.Master.
It is too difficult make any refactoring and rename without it
Maybe, visual studio have never had such feature. Previously I have used Resharper but now I can't use it.
The same true for visual studio 2017. windows 10
I suggest you could try the following suggestions:
1) disable any third party vs installed extensions under Extensions-->Manage Extensions-->Installed
2) clean nuget caches
3) run update-package -reinstall under Tools-->Nuget Package Manager-->Package Manager Console.
4) close VS, delete all the folders C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio\16.0_xxxx to initialize your VS.
also, for your project, you should delete .vs hidden folder under the solution folder, bin and obj folder of your project.
Besides, if you still cannot get what you want, please click C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe to clear all vs versions strongly, their registry information and data info.
Then, reinstall the VS again. If you have tried this step, then, you should try to turn off any antivirus software, other third party windows programs.
Update 1
Actually, it is quite strange. As to help you further, I have reported the issue on our DC Forum and you can vote it and add any comments if I did not describe the issue in detail so that it will get more Microsoft's attention. And I hope the Team will give you a satisfactory reply.

Visual Studio 2015 designer.cs file gets all custom components removed

I am using Visual Studio 2015 on an ASP.net WebForms project. When I save a .aspx page the .designer file gets regenerated but it removes all references to any custom component on the page (ex: ) and leaves intact the references to any default built-in .net components (ex: ).
The problem is only happening on my machine. The other team members do not have this issue so I know there is not something wrong with the project itself.
One thing I have found is that any time I add or remove an extension in visual studio, it shows the Restart button. When I click that button to restart VS, then the problem with the designer files goes away. But as soon as I manually close VS using the X at the top right, and restart it, that is when the problem comes back.
I've tried with and without using Run as Administrator with no luck either way.

upgrading to framework 4.0

I have a solution which contains 18 projects and targets framework 3.5. It also includes web installer project. When i am trying to upgrade the solution to framework 4.0, it gives me lots of errors and doesnt convert web projects and web installer projects.
Is there a way to convert projects manually rather than relying on visual studio wizard?
.wdproj files are not getting converted.
Error Log:
Project file opened successfully
No Conversion Required
Get root element Project successfully
No Conversion Required
ToolsVersion in String:
3.5
ToolsVersion in DWORD:
3.5
Require Upgrade
Ready to exit
Require Upgrade
I understand that you want to change your framework for all the solutions from 3.5 t0 4.0
I think you can set that in visual studio 2010.
Open your entire solution in VS2010.
right click on the project (do this for all the projects you have)
then select properties.
Click on compile tab on the left side .
click on advanced compile options
change the target framework to 4.0
I'm not sure but I thought of sharing this idea.
Let me know if this works.
I always have kind of a hard time finding the setting in visual studio for changing the version of .NET. And even then sometimes it has been greyed out (unchangable) through VS GUI. The way I typically change .NET is by opening your .sln file in notepad. In a Visual Studio 2010 .sln file there should be a line in there something like:
TargetFrameworkMoniker = ".NETFramework,Version%3Dv3.5"
Just change it to:
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
Save, and you should be good to go.
If you really want to change your framework through the GUI in Visual Studio 2010 for an asp.net project you can right click on your website (one tier under "Solution" in "Solution Explorer"). Select "Property Pages", then in the new window "Build" which has a field called "Target Framework" where you can change your .NET Framework.

Is There a Visual Studio 2005 ASP.NET debug and release build

Is there a "debug" and "release" build in VS 2005? If so, how do I switch between the two?
Saif:
Are you working on an ASP.NET web site project?
If so, Visual Studio delegates the build step to the ASP.NET runtime, and the ASP.NET runtime picks up debug versus release in the web.config .
I have a post on the topic that will help: Debug and Release Builds in ASP.NET 2.0
Note that a couple things have changed since that time. Namely, MSFT released two add-ins for VS 2005 - one to add real web application projects that have debug and release settings (for the code-behind and loose c# files), and they also released web deployment projects, which can use the asp.net command line compiler. Web App projects became a part of VS2005 in SP1, too.
Use the Configuration Manager. Right-click on your solution in the Solution Explorer, select "Configuration Manager...", and change the active solution configuration.
You can change your project's behavior when in debug or release mode. Bring up your project properties pane, select the appropriate configuration from the dropdowns at top, and change the settings as appropriate. Notice that some changes are made by default for you. For instance, release builds by default are set to optimize code, and debug builds are not.
In the ASP.NET web.config file there is a debug="true" attribute. The first time you run the web application Visual Studio will ask you if you want to turn on debugging, selecting yes will cause Visual Studio to edit the config file for you.
Just remember to make sure you change that back to false for your release builds. For more info click here.
The quick way is to right click on the toolbars and turn on the standard toobar. Then you can quickly change between build targets by choosing the one you want from the solutions configuration drop down.
If you want to change what those configurations do, then follow what Michael Petrotta said in his answer.

Resources