MVC Requires Rebuild After Modifying View - asp.net-mvc

I created a new MVC 4 project with a blank internet application template in VS2012 Ultimate.
For some reason this project requires me to stop and recompile when modifying even just a view or CSS file. Is there a VS setting or project setting I'm missing here? I understand that I should have to stop for modifying class files, but why am I having issues with the view?
-Ninja

My best guess is that the hosted code is at a different location from where it should be for a default VS solution.
The solution building is copying the code from you solution\project folder into the different location.
Try to check the location of the actual deployment. Depending upon whether you are using IIS, IIS Express there are different ways to know that.

Related

Controllers folder missing Umbraco 8

I installed Umbraco 8.4 as per the instructions found at https://our.umbraco.com/documentation/Getting-Started/Setup/Install/install-umbraco-with-nuget
Once done within Visual Studio 2017 i tried to created a new Controller and the folder (Controllers) was missing.
I'm not sure if i've missed something but i didnt want to create the folder manually in case it introduces new problems later down the line.
I thought to recreate the project but instead of selecting Empty as the project to use MVC but after reading through a few threads it seems the correct way is to select an empty project.
Under the bin directory i do see System.Web.Mvc.dll
Am i missing something?
You should definitely not use the MVC project template when creating a new project - that will add all sorts of dependencies that will likely conflict with what comes with the Umbraco NuGet package.
Go with the "Empty" template and then add in the NuGet and it will give you the dependencies you need for Umbraco to run. If you need to add in other stuff from MVC afterwards, you can add these in a version that aligns with what the Umbraco package has added.
In regards to the Controllers folder - it really doesn't matter where this folder lives or what it is called. Controllers are registered by other means. You are totally fine to create this folder manually and call it whatever you prefer.
I think most people actually prefer to keep Controllers in a completely separate project in the VS solution. Then reference that project by your main project to ensure the compiled DLL is included in your web project - and thereby your controllers can be used by the Umbraco website itself. By doing this, you get a clean separation of your .cs source files so you won't accidentally be deploying those when you deploy your site. To do this you would of course require to add UmbracoCms.Core NuGet package to your other project in order to use Umbraco functionality.
Keep in mind if you are adding plain MVC controllers (not inheriting from the Umbraco base controllers - and therefore not getting automatically registered) you will need to manually register these controllers in the route table in order to access them.
This is no different from what you would do in a normal ASP.NET MVC project, but since this isn't added by default in an Umbraco project - you need to do it yourself.
See this answer for instructions on how to do it: https://stackoverflow.com/a/56972929/336105

Did VS2013 incorrectly upgrade my project files?

I had a solution that included both an ASP.NET MVC web project and a WebAPI project. The solution was created originally with VS2012, but I recently upgraded it to VS2013.
I just noticed when going to add a controller that I'm not getting the correct options in the right click menu. For instance if I go to the web project and right click the controllers folder, the option to add a controller isn't there. Instead I have add WebAPI controller. It's exactly the opposite for the WebAPI project.
Things seem to build and run ok so far, but it's going to be a pain manually adding things and I'm wondering if something else might break. Any idea why this is happening or how to fix it?
I would guess that project type is different in your csproj. Take a look at this question:
What is the significance of ProjectTypeGuids tag in the visual studio project file
Here is what I have on my machine for c# asp.net mvc project:
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
Take a look at your guids and see what they mean.
You could see the meaning of the different GUID in the register :
•HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Projects for
ProjectTypeGuids
•HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Packages for
packages reference by some project

Can not remove Default.aspx from Asp.net MVC 3 Application

I am working on a project that started out using ASP.Net MVC 1 and has since been upgraded to ASP.Net MVC 3. It is my understanding that if I am running my ASP.NET MVC 3 app on IIS 7 using the integrated pipeline that I no longer need the Default.aspx file. However after I have removed the file from the project and physically deleted it I get the following error every time I try to compile in Release mode:
Description: Could not load type 'ProjectName.Default'.
File: Default.Aspx
I have verified that there is no instance of ProjectName.Default or Default.aspx in my project file. I have even done a grep search in all of my files in the project for any mention those names and still have found nothing. What do I need to do to be able to remove Default.aspx from my ASP.Net MVC 3 app and get it to compile in release mode. It compiles just fine in Debug mode by the way.
From the debugging listed here you probably had a cached version of your compiled code. While Visual Studio builds the code behind files into a single DLL, ASP.NET compiles each aspx file into a DLL as well (depending on how you configure it, there can be variations on this). These DLLs are located at %WINDIR%\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files note that this directory is sensitive to .Net version, could be in 2.0 or 4.0, it is also in some way dependent on bit-ness, as there is a similar directory in Framework64.
I tried to clean my solution, delete the project temp files, remove all the leftover crud I could think of. Unfortunately none of this worked so I had to take the brute force approach and checkout a new copy of my project. After doing this I no longer had the error occur when building the new copy that had Default.aspx removed. Unfortunately this solution did not provide me any insight into what leftover file Visual Studio was holding onto.

MVC 3 Views not deployed

I have been working on a small project on recent delived ASP.NET MVC 3 RC. The issue is that when I try to deploy my website via File System, certain views of my website are not deployed. The site gives me error when i copy same deployed site to my hosting. When I manually copy views to hosting, it works ok.
Now this thing is not breaking anything as such, just want to know that if I am missing something while deploying my site. I am not sure why few views are deployed and why not others. Seems very random to me.
Thanks,
If you created the app before RC (aka using our Beta) we had a bug in which we didn't mark the views as "Content". New apps using the RC have this bug fixed, but if you open an existing project, it doesn't automatically fix up the existing files.
To fix them, select the file and in the properties pane, set the Build Output to "Content".

Can you convert an ASP.NET MVC Application to a Web Site using ASP.NET MVC and what problems might you run into?

I would like to use a WebSite project instead of a Web Application project for an MVC project.
What is the best way to accomplish this and are there signifigant problems that I might run into?
(as a side note, my reasoning for wanting this is because I have graphic designers who put files into SVN but they don't get added to the "project" and don't show up on deployment or deployment testing. My thought was that switching to a Web Site project might prevent this)
You don't need to do anything special if you are not using CodeBehind files (if you're using them, it'll be more complex but anyway, it's an MVC app. If you're using them, don't!). Just take an MVC Web app project and put all source files (*.cs) under App_Code directory of the Web site. That said, I fail to see any advantage for it.
The application project allows you to use the Models folder to embed classes into. This would then be compiled for that web project. A web site does not provide for this directly. It would require that you use an assembly project to maintain all of your classes. Rather than converting from one project type to another (which I am not sure how you wold go about doing that) you can simply attach an assembly project to your web application and not store any classes in the model folder of your application.
Having said this, you should keep your web project as an application as there usually are view specific classes that are required such as a your view model classes that belong in the web project.

Resources