OpenIdPortableArea using Razor fails - asp.net-mvc-3

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!

Related

Blazor components - namespace move

I am experiencing problem in VS 2022 in Blazor complex project. After moving Blazor components to different namespace/folder the components are not functional any more. My component does not 'recognize' other Blazor components anymore. For example custom component MudTable from MudBlazor namespace:
I would like to be able move Blazor components easily as simple classes.
Sometimes it helps to specify the same namespace in razor file to match namespace in partial code behind class, but sometimes I end up creating component (razor and cs files) with different name (copying the same code). This is very time consuming. I am not able to reproduce the described bug in Simple Projects. I have tried to reproduce the issue but it works fine (with minor VS bug) as described below. I will keep trying to reproduce the issue on Sample project.
Please find below scenarios working fine:
Simple scenario working fine
Steps to reproduce the issue:
Create Blazor Server App
Create folders
Components
Components\Sub1
Components\Sub2
Add new Razor component e.g. MyComponent1.razor to folder Components\Sub1
Verify that <MyComponent1\> works on some page. Eg. add lines to Index.razor:
#using BlazorApp1.Components.Sub1
<MyComponent1 />
Move MyComponent1.razor to folder Components\Sub2
Update Index.razor:
#using BlazorApp1.Components.Sub2
<MyComponent1 />
It works fine
More complex scenario with minor bug
Create Blazor Server App
Create folders
Components
Components\Sub1
Components\Sub2
Add new Razor component e.g. MyComponent1.razor to folder Components\Sub1
Add behind the class to 'MyComponent1.razor.cs' to folder Components\Sub1:
using Microsoft.AspNetCore.Components;
namespace BlazorApp1.Components.Sub1
{
public partial class MyComponent1:ComponentBase
{
}
}
Verify that <MyComponent1\> works on some page. Eg. add lines to Index.razor:
#using BlazorApp1.Components.Sub1
<MyComponent1 />
Rename folder Components\Sub1 to Components\Sub1Renamed.
Visual studio does not display any error and project can be compiled/started. Code behind is even displayed 'linked' to razor file:
This seems as a VS bug to me.
When project is started Component1 is invisible on Index page, because component 'BlazorApp1.Components.Sub1.Component1has no visual code defined, because it has only non-visual definition 'behind the code'. The file 'Component1.razor' with visual is not used at all because it is in unused namespaceBlazorApp1.Components.Sub1Renamed`
Update Index.razor:
#using BlazorApp1.Components.Sub1Renamed
<MyComponent1 />
When project is started, Component1 is visible on Index page (but I assume that no code behind is processed)
Do you have any hint, how to make it work for blazor components ?

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.

Cannot get Razor intellisense

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

Resources