Where are the predefined file templates located for Razor? - asp.net-mvc

I've just started playing around with JetBrains Rider IDE using one of my existing ASP.NET MVC projects. When attempting to create a new Razor View from template, I've been unable to find any templates which refer to Razor as stated here. These are all the templates I can see when adding a file template to a chosen folder.
Am I missing something like a plugin, nuget etc...? If worst comes to worst, then I don't mind creating them, it's just a slight annoyance that it clearly states they should be there.
OS: Windows 10 Build 17134
JetBrains Rider: 2018.1 Build #RD-181.4379.1191, built on April 14,
2018
Update
I've raised this with JetBrains support and so far they've advised that some predefined templates (Razor being one) are only available in subfolders of Views folder. More info can be found here. Sadly it's still not working for me but thought I'd add as it may help someone.

It's a bug! It's seems to be okay when creating a new solution but then at corrupts the template analytics when updating nugets and/or adding OWIN (I'm guessing the Startup.cs in the root of the project has something to do with it as well).
YouTrack: https://youtrack.jetbrains.com/issue/RSRP-469774
Update
It took nearly 5 years but they finally fixed it. I don't even use that IDE anymore lol!

Related

Created A New MVC Project In VS2015 And Intellisense Produces Error In Razor View

I just created a new web application (MVC 5.2.3) in Visual Studio 2015, and I regularly get errors like this on the HtmlHelpers:
I'm using .NET 4.6 (the default project was set to 4.5.2 originally, however I still had this issue with that default setting). I've looked at a bunch of similar questions on this site, and yet I haven't found a solution that consistently works. Any advice?
This sounds like a corrupted MEF cache to me. Different user, different MEF cache.
The PM of Razor Editing, Mads Kristensen, wrote an extension to make clearing the MEF cache simple. Try this: Clear MEF Component Cache.
You'll just have to restart VS after clearing; rebuilding the cache takes seconds, not minutes.
Please let us know if this solves the problem for you.

Upgrading to Visual Studio 2015 renders intellisense broken for project

I've been through a lot of similar issues, but could not find anything that worked for me.
I'm upgrading my IDE from the VisualStudio for Web (v10) to Visual Studio 2015 (v14, I guess) Community Edition.
The main project that I'm trying to use on the new IDE is a MVC 5 (5.2.3), with EF 6.1 (6.1.3) and a bunch of other stuff.
Problem is: When opening the project on the new IDE, everything looks fine (it even compiles and work). I got the MVC context menu working on the project explorer (showing the "Add Controller..." and "Add View..." when appropriate). Only (really annoying) thing is the Razor Intellisense.
When I do open a View file (.cshtml) I receive warnings on several helpers, some of the "using" are greyed out (even though they're supposed to be needed) and the #model myModel is shown like everything after the #model directive is not razor (it's treated like HTML by the intellisense coloring).
What I've already found and tried:
I've already tried to clear the UserData from the vs (devenv /ResetUserData)
I've already tried to run the VS2015 in safe mode
I've already tried to run VS2015 as Administrator
I've already tried to set the Project's target framework to 4.5.1 (used to be 4.5)
I've already tried to open the project on Visual Studio Community 2013 saving it there before trying to use it on VS2015.
When creating another MVC project from the VS2015, everything works fine.
Here's an example of the annoying issue:
Ok, finally got it.
Posting what I found out believing it may help someone else:
What seems to cause the problem mentioned is the fact that the project was created on an old MVC version (with older Razor, EF, etc).
As stated in this answer: Visual Studio 2015 Razor View MVC Types not recognized, VS2015 tools may not work for older MVCs.
The solution is to update all your packages to [at least] the minor versions accepted on newer MVC (5?). To do so you can use the list in this website: http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2.
Once everything is up-to-date, open the web.config files located on root of your application and on the Views folder. In there, you will probably find some references to the older versions of MVC and Razor. Update those versions values (all of them) to match the updated versions of your packages (you may create a new empty MVC project on the new Visual Studio and check for those values as a hint of what they should be).
This step is the catch! Since, even if you update you project's packages, some web.config references may still mention the original versions.
Clean the solution (Build > Clean Solution) and close the project. Reopen and compile it. Now [hopefully] everything should be working fine.
[Edit]
One more thing: If your project was also updated from Framework 4.5 to 4.5.1 during this IDE transition, you should also install a NuGet package called "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" (as stated in https://support.microsoft.com/en-us/kb/3025133).

Monodevelop MVC3 razor - what is the trick to get it to work?

I use monodevelop 3.0.4.7 and mono 2.11.4 on mac OS 10.8.
When I create a new solution from scratch in monodevelop I can create several types of ASP.NET mvc3 projects with razor views, but the projects get created with references to system.web.helpers and system.web.webpages that are "not available for Mono/.net 4.0 in mono 2.11.4" and won't build.
If I change my .net version to 4.5 in the project options I get the system.web.webpages reference resolved, and if I simply remove the reference to system.web.helpers I am able to build the default site. However, it is unable to make use of .cshtml views, it only looks for aspx views.
I have tried different things related to references and versions of mono, changing the viewengine to razor in global.asax.cs and even copied dll's from a windows-based asp.net mvc application, but something new breaks all the time.
It seems strange that there are project types included that don't work from scratch, so I'm guessing/hoping I'm missing something much simpler?
I was sitting with the exact same problem, on Linux though, so I decided to ask on the mono mailing list (see the answer to my question here: http://lists.ximian.com/pipermail/mono-list/2012-October/049022.html).
The short answer is: no, you're not missing anything simple.
Long version: The current version of mono is not compiling the System.Web.Helpers.dll, so you have to do some footwork your self, to get it compiled. That is described in the link above.
I guess we just have to wait a little longer before this becomes part of the mono framework :/
I happened across a solution for this issue here:
http://blog.miraclespain.com/archive/2013/Jun-24.html
Basically in xamarin studio you can add a version of nuget from the following add-in repository source:
http://mrward.github.com/monodevelop-nuget-addin-repository/4.0/main.mrep
Once nuget is installed, you can create a new mvc3 razor project, notice the missing references for system.web.helpers and system.web.pages and just remove them, then use nuget to add the microsoft aspnet web pages 2 package which solves the missing references.

MVC 2 to MVC 3: MvcScaffolding fails due to "could not load file or assembly" error

Setup:
I am using MVC 3, EF 4.1, Visual Studio 2010 SP1 with Power Tools updated to latest version.
With the above installations, I don't need the NuGet packages that were required previously. Everything is RTM.
The project has been upgraded from MVC 2 to MVC 3. I initially tried the upgrade tool, but that gave me grief, so I did it manually as per the instructions in the MVC 3 Read Me file.
Problem:
When trying to use the new scaffolding of controllers and views for CRUD functionality (against Code First DbContext), the scaffolding fails with the error:
Could not load file or assembly 'file:///C:\[PATH TO MY APP]\bin\Lanap.BotDetect.dll'
or one of its dependencies. Operation is not supported.
(Exception from HRESULT: 0x80131515)
Question:
Lanap.BotDetect is a Captcha control. It works fine and is there, I use it in other pages no problems, the solution compiles, etc, etc. So there is no problem with this dll.
However, this error is stopping me using the new scaffolding capabilities.
I can't see what it has to do with the scaffolding of a new controller and its views, so there must be some configuration that is wrong.
Any suggestions as to where I can look? Googling has drawn a blank.
EDIT 1:
I am trying to see the failed assembly binding using Fusion Log as suggested in a comment. No failed binding showing (but that might be my fault) but the question remains:
Why would MvcScaffolding NEED to load the Captcha .dll at all? It is just scaffolding a controller, and nothing in the T4 says anything about this .dll
(NOTE: I haven't edited the scaffolding T4 code)
EDIT 2:
I tried removing the reference to Lanap.BotDetect, and the error changed to not being able to open the config file that has the connection strings (I shunt the connection strings out to a db.config string, just gives me less visual pain when looking at a config file).
I am giving up on scaffolding on this app. It works in clean, new apps, but not this one where there is a lot of pre existing code.
I found another solution to this. Turns the issue for me was that the issue was it was being built over a network drive. So when I moved the project over to a location local to my machine and rebuilt the project it corrected everything. I detailed everything with screen shots and here...
http://ryandunn.co/mvc-growing-pains-could-not-load-file-controller-dll
Put simply check the location of your project and move it to C: after that a quick rebuild had me back and working normally.
So I know that you have moved on but I ran into the same problem and just found the solution. It turns out the error is due to the assembly not being trusted i.e. you downloaded it from the internet.
You can right click the .dll and unblock it to fix the problem. For info on how to unblock see the following
http://blogs.msdn.com/b/brada/archive/2009/12/11/visual-studio-project-sample-loading-error-assembly-could-not-be-loaded-and-will-be-ignored-could-not-load-file-or-assembly-or-one-of-its-dependencies-operation-is-not-supported-exception-from-hresult-0x80131515.aspx

ASP.NET MVC Upgrade guide

I have a small ASP.NET MVC application developed using the latest beta version.
What would be an easy to follow step-by-step guide to upgrade to the RC released yesterday?
What key changes would I have to apply to get it working in the new version?
Read the release notes, the steps to follow are listed there.
Repeated here for your convenience.
There are not many changes between the Beta and the RC releases. However, you will need to make a few changes to your applications after installing the Beta release. Most of these changes are apparent when you try to compile your application by using the latest release, so we do not list every possible change.
The following list describes some of the changes that you must make.
Update the references to the
following assemblies to point to the
RC versions:
System.Web.Abstractions.dll
System.Web.Routing.dll
System.Web.Mvc.d
ll
Note If you are running ASP.NET 3.5 SP1, you need to update only the System.Web.Mvc assembly reference.
By default, these assemblies are located in the following folder:
%ProgramFiles%\Microsoft ASP.NET\ASP.NET MVC RC
After you have made these changes, compile your application and resolve any compilation errors. Most of the errors will be the result of one of the breaking changes listed earlier.
Update the section the Web.config file In the Views folder to match the following example. (The changed elements are in bold.)
I think the release notes has a fairly good guide.
There's some issues not mentioned in release note. Read this for more info:
http://forums.asp.net/t/1377139.aspx
You also make sure to add the following tag to your web.config file:
<system.web.extensions/>
It took me a lot of effort to figure it out since it's been nowhere documented.

Resources