Cannot get Razor intellisense - asp.net-mvc-3

Having done everything I have found I still cannot get Razor Intellisense to work in Razor views.
I have several squiggles in the web.config file in the Views folder. I have a reference to System.Web.Webpages.Razor in my project but the web.config file still cannot resolve the 3 references in configSections and the error for WebViewPage says it must be convertible to System.Web.UI.Page
What to try next?

The problem was that there was still a remnant of MVC2 left on my computer. Uninstall did not completely remove it and the couple of files left stopped the new MVC 3 installation from completing correctly. I apologize for not having the url handy, but someone blogged on this subject and gives you a step-by-step how to. I had to do even more than what he suggested, but that was the solution...to clean every last remnant of MVC 2 or MVC 3 CTP from your computer

Related

View Component Tag Helper Not Recognised In .Net Core 3.1

I am trying to use View Components using tag helpers in a Razor page in a new ASP.NET Core 3.1 project.
Invoking as follows works:
#await Component.InvokeAsync("LeftSidebar")
Using the tag helper however doesn't and what's more Visual Studio does not seem to recognise the "vc" tag at all:
<vc:left-sidebar></vc:left-sidebar>
I have added the "addTagHelpers" to the _ViewImports.html file but it's not picking it up. I also read somewhere it requires a model so tried doing that with no joy.
Anyone else had this? Literally have wasted hours and will go back to the non-tag helper syntax for now.
My mistake was including a ";" at the end of the add tag helper in the _ViewImports file.
Fixing this, cleaning the project and rebuilding everything sprung to life.

The type or namespace name 'DotNetNuke' could not be found

I built a custom theme for DNN several months ago using the Christoc templates for Visual Studio. I needed to make a small HTML adjustment today so I re-opened the solution and made the change but when I rebuilt the project, I get several build errors, presumably because it no longer recognizes my DNN dll:
The type or namespace name 'DotNetNuke' could not be found (are you missing a using directive or an assembly reference?)
I checked my C:\path_to\dnndev.me\bin\DotNetNuke.dll and it's still there so I'm not sure why Visual Studio isn't seeing it.
When I built the skin originally, I was running DNN 9.1.1 but have since upgraded to 9.3.2. Could that be causing my issue?
I read elsewhere that I could be building on the incorrect version of .NET framework but I don't know what version to use for DNN 9.3.2 so I tried several different version with no change in results.
How can I solve this issue?
UPDATE:
Per the answer here, I rebuilt with .NET 4.7.2 and it did not solve my issue.
UPDATE 2:
Okay, so the small change I made was adding another layout page like the Home.ascx and Edit.ascx files that come with the template. If I remove the new layout files, the project builds fine.
What could I be doing wrong when adding a new layout?
What you read about the .Net framework version is correct. You need to 4.7.2.
The problem was a new layout I had created. I right clicked on the project and selected Add > New Item and chose Web Forms User Control. This was the wrong way to add a new layout.
I successfully added it by copy/pasting one of the template's pre-existing layouts and renaming it. The project builds fine now.
Ah, now I understand what went wrong. Adding a Web (Forms) User Control is not completely wrong, as a skin (or theme) is a kind of Web User Control, and has the same extension (.ascx).
What you have to do is deleting the code behind file (.ascx.vb or .ascx.cs), and change the first line of the ascx file to
<%# Control language="vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %>
(But copying another skin file is also a good solution as propably you have most of the references to the skin object already there)

References for MVC extension methods differ between vbhtml and cshtml files?

I am converting the login views of an application from vbhtml to cshtml. In the vbhtml files the original developer calls an Html.LabelWithAttributesFor extension method. When I write the same line of code in the new cshtml file the extension method isn't available via Intellisense and fails to compile. Are references not shared between vbhtml and cshtml files in a project?
Wanted to circle back and close this question with the "answer". In the end, what seems to have knocked something loose was when we removed the vbhtml pages from the solution. All use of the Extensions had been removed prior to our removing the vbhtml pages and other developers had worked on the solution in the interim making other changes. Fast forward a few months to another developer needing the extensions. He added a reference to the project with the extension methods and used them on a new cshtml page, which worked fine. So, the problem is solved but I still have no idea what caused the problem in the first place and I have been unable to reproduce it.

Global.asax.cs is not visible at the server

Running under Server08 | IIS7. I have a website project and am in the habit of hand editing the Global.asax.cs at the deployed site many times in the past. Recently I've found that only the Global.asax is present and has only:
<%# Application Codebehind="Global.asax.cs" Inherits="myDomain.MvcApplication" Language="C#" %>
There are simply no Global.asax.cs files present/visible for any of my active, functioning websites anymore.
I've checked here Global.asax can't find code-behind class and here where is the codes in Global.asax in mvc3? without getting anywhere. The second link contains the comment: 'That's because it's a compiled web application. You'll have to view it in Visual Studio as a project.'
But since my project has always been a website - and I've not converted it (intentionally) I'm puzzled by the changed behavior.
But when i step into VS12 and look at the context menu for the solution's WebProject it presents 'Convert to Web Application'. The sites' folder structures do not contain App_Data or App_Start. To my mind, these 2 fact establish at VS is treating the project as a website, why then, is the Global.cs compiled down to the /bin?
I'll close by repeating - I've hand edited these things in the past - I'm not positive but it's probably accurate to say that this is the first time I've tried to do so after installing VS12. And, coming to think on it harder - it's only recently that I've implemented the 'One Click Publishing' service so that could be coming into play.
verify? I'd like I need to edit a simple update without full re-deployment.
thx
I think the 'One Click Publishing' is most likely the culprit here. I created a sample Web Site project to experiment, and when I use the publish feature in Visual Studio, the files generated are indeed missing the Global.asax.cs file. Instead, a bin folder is created with a compilation called "App_global.asax.dll" even though it is a Web Site and not a Web Application. I am guessing this might be similar to what is happening for you as well.
If not, I found a link which might be useful to you in order to once again be able to edit a class on the server. Particularly, have a look at the second answer (the one not accepted as the best answer) to recreate a class file for the global code: Where is the Global.asax.cs file?
I tried this solution, and verified that the class file is editable on the server, and that it is dynamically compiled at run time (the modifications I made to the file worked immediately).
Hope this helps!
After editing the global.asax you need to rebuild and upload the DLL to the bin folder. Otherwise, your changes will not take effect.
You might be able to upload an web version of the global.asax that includes the code in that one file, which obviously does not require a .cs code behind. I used to do it with aspx files in an application but I have never tried it in the GLobal.asax file.

OpenIdPortableArea using Razor fails

I'm trying to get the OpenIdPortableArea to work in my ASP.NET MVC site using Razor.
But when I click the Login-link (created by the LoginStatusWidget supplied by a OpenIdPortableArea helper) I get the following error:
The file '/Views/Shared/Site.Master'
does not exist.
That's true of course since I'm using Razor and my "master" is _Layout.cshtml. From the source () of OpenIdPortableArea it looks like it should support Razor views but I cannot understand how.
Anyone got any input on that?
OK - the answer was quite simple - that version (1.0.0.3) didn't support Razor.
But just a few days after that a new release was created and 2 different packages on NuGet was added. One for Razor and one for WebForms:
- http://nuget.org/Packages/Packages/Details/OpenIdPortableArea-RazorViews-2-0-0-0
- http://nuget.org/Packages/Packages/Details/OpenIdPortableArea-WebFormsViews-2-0-0-0
That worked much better!

Resources