Before upgrading my web application to .NET 6 a was able to scaffold Razor views with custom templates located in ProjectRoot/Templates/ViewGenerator as shown in this image. This allowed me to override default templates. After upgrading to .NET6, VS2022 is using default templates to generate these views. I tried to find some info about the new path it's expecting but i had no luck. Any help is really appreciated.
Related
I have one Asp Dot Net Core project, using Razor page, that is the ClientApp.
I create a new projet, using Blazor, that is the AdminApp.
I reference the AdminApp within the ClientApp.
I would like to call the AdminApp, from the ClientApp, when url is "clientapp/admin"
I cannot make it work.
Could you help me ?
Personally I would convert the ClientApp to blazor which should just require a couple lines being added to the startup.cs and then you can just import Admin components or update the route on top of the admin pages to include /admin/admincomponentname
This is the beauty of Blazor since serverside Blazor is essentially just razor pages with a small difference engine to run like a SPA.
I used to embed some of my Razor views for mailing in a class library which was using ASP .Net Core 2.1.0-preview1-final and it was working fine.
Here is the configuration in the .csproj file:
Since I upgraded the .Net Core version to 2.1.1 which is the final one, I can not use the embedded views anymore.
I know about the new Razor Class Library concept but I need to pass my views to a ViewRenderer service which basically converts the view to string to be sent as an email.
The viewrenderer service was finding the views before but now it doesn't find them and I get the following error:
VIEW does not match any available view
How can I fix this issue?
I was facing the exact same issue, setting CopyRefAssembliesToPublishDirectory to true in the csproj file fixed it. your csproj file should look like this :
...
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory>
</PropertyGroup>
...
When using #inherits in a razor template view in portable library for a Xamarin-based hybrid app, the intellisense is broken such that it red-underlines the functions provided by the base view class such as "#Model". I have a fresh update of the Xamarin tools (4.1.0.530).
The first fix here doesn't apply: Xamarin WebView - No Intellisense in razor
I'm not sure if this is related, but the RazorTemplateProcessor doesn't seem to be reading my web.config such that I also have to reference class names fully qualified, or the generated code-behind file will have a compile error. How to get it to support web.config?
So, i'm developing my razor macroscripts in Visual studio for my Umbraco project.
Everything is working fine, but there are two things really annoying.
If I want to make a new CSHTML file the best solution for this is to duplicate an existing file.
I dont have full razor IntelliSense like e.g. Html.Raw
Is there a way to configure my project to use this features? Didn't find a .cshtml template yet.
You need to have the MVC Framework installed, then when you open the project as a website, you should be able to create and edit cshtml files with syntax highlighting. See my answer to the following post for more details:
Setting up local development environment for Umbraco
If your project is a web site/application then the mvc templates aren't available (they only show up in MVC projects). You can just create a text file and name it with the .cshtml extension though (you could set up your own template for this in VS if you wanted to).
To get intellisense in your Razor files, see Doug Robar's blog post on the subject
As an alternative if you go into the Umbraco admin, go to the 'Developer' section and right click on 'Scripting Files' you can create razor scripts directly (and this will save the new .cshtml directly into your 'macroScripts' folder - although in VS2010 you will need to right click on the new script and choose 'include in project').
Also this will allow you to base your new razor macroscript on one of the pre-built snippets so you may get a bit of core functionality for free.
From Umbraco 6 on it's very convenient to install Umbraco on your local file system with Visual Studio and NuGet. Given that you have the MVC Framework installed and you use Visual Studio 2012 or above, you get full Razor support in Visual studio.
Umbraco Our has a great blogpost about this where they described the steps below in detail (with screenshots!).
Create an Empty Web Application.
Install Umbraco using Manage Nuget Packages ('Umbraco CMS') or the Package manager console (Install-Package UmbracoCms)
NuGet will then download dependencies and will install all of Umbraco's files in your new solution. During this process it will ask if it is allowed to overwrite your web.config file. (Make a back up of your existing web.config if you install Umbraco in an existing project)
Finally, don't forget to run your project hitting F5. You'll see that whenever you try to add or edit a file in your views folder you have razor support and intellisense
After upgrading a working MVC 3 solution with Razor views to the MVC 4 beta, I get the message "} expected" from files called App_Web_2x0hrczu.0.cs and App_Web_supamddr.3.cs. They're generated files, obviously, but they appear to refer to a partial view (a .cshtml). Everything used to work, so I'm confused! Any ideas?