MVC.NET Razor views rendering differently across deployments - deployment

I have a razor view in an MVC4 project that treats the same input differently in two different environments. I have a script block within an MVC section.
At my live deployment, whenever I create a less than comparison (if(a < b)), the < will be interpreted as a HTML block, and the section will render in a weird manner. Currently, I have to use Html.Raw("<"). At my development machine, I do not have this issue.
I'm sure there's a simple answer to why razor doesn't realize that the < is part of my javascript, but right now, I'm only interested in why the behavior would be different across delpoyments. I know both setups are running razor v2, since new features like conditional attributes are working in both.
What could be the cause of discrepancies such as this?

Check the file version of System.Web.Razor.dll in both environments and see whether it's 2.0.20715 in both places. We did release an update to Razor v2 that's included in the MVC 4 installer via Web PI, but isn't in the box in Visual Studio 2012, which might account for the difference in behavior that you're seeing.

Related

What is meant by "it has Tooling Support"?

I tried to follow Microsoft guidelines for Windows Applications. I will write apps using .NET MAUI.
Straight off the bat I noticed this .xaml file in the Quick Start MAUI project I created in VS2022. Personally I hadn't encountered these before, so I went to read about them.
At the Learn.Microsoft website it states this:
XAML allows developers to define user interfaces in .NET Multi-platform App UI
(.NET MAUI) apps using markup rather than code. XAML is not required in
a .NET MAUI app, but it is the recommended approach to developing your UI because
it's often more succinct, more visually coherent, and has tooling support
What does it mean "and has tooling support" in the context of using XAML, as opposed to just purely C#?
Just as Steve suggested, with the assistance of XAML Hot Reload, it can enable you to view the result of XAML changes in your running app, without having to rebuild your project. Without XAML Hot Reload, you have to build and deploy your app every time you want to view the result of a XAML change or in C# code(purely C#).
Also, XAML has several advantages over C# code(purely C#):
XAML is often more succinct and readable than equivalent code.
The parent-child hierarchy inherent in XML allows XAML to mimic with
greater visual clarity the parent-child hierarchy of user-interface
objects.

Does MAUI support loading and displaying child forms inside a parent

We have a winforms application that uses parent/child forms written in .net framework. With .net framework being retired we are evaluating which .net core technology we should be looking at to convert our application to.
One of these technologies we are looking at is MAUI, there is some appeal to making our application cross platform however there isn't a lot there yet on this besides the very simple tutorials put out by Microsoft.
Does MAUI support loading and displaying child forms inside of a parent?
Or is it like WPF and only support custom controls?
Any guidance is greatly appreciated.
Depends exactly what you mean by a "form".
In Maui, by definition, a Page fills the window.
Its easy enough to make a ContentView that contains a "form". BUT, similar to WPF, you won't have some "lifecycle events" on those views. E.g. there is no event when a ContentView appears. A work-around is to put needed logic in constructor, OR have constructor attach an event handler to the containing page's OnAppearing method.
Bottom line: Its similar to WPF. But there is a work-around for whatever functionality you are accustomed to at the "form" level. (BTW, similar work-around is possible in WPF.)
For a more detailed answer, you'll need to research Maui, attempt to write equivalent Maui code. If you get stuck, Create a new question with the original WinForms code and the Maui attempt (that does not work). Explain what you want to happen, and what actually happens (or does not happen).
Bonus Tip: If you only need to run on Windows, then WinUI 3 (aka Windows Desktop App) is an alternative that may give you more functionality that you are accustomed to.
Importantly, mouse/keyboard/tooltip support in Maui is currently limited to what makes sense on mobile devices. No event for mouse hover - which also means no tooltips. No "global" key hooks (an Entry has a TextChanged event, which sees each character added to that Entry, when it has focus. But that doesn't help if you want a key to do something when no text element has focus.)
[OPINION] Full mouse/keyboard/tooltip support is often requested; I expect some solution sometime in 2023.
Bonus Tip #2: WinForms has been migrated to .Net 6+. [OPINION] Microsoft seems committed to keeping it alive. I wouldn't develop a new app on it, but for legacy WinForms code that would be the "cheapest" development option. Long-term, I would favor Maui for cross-platform, WinUI 3 for Windows only.

Are there any alternatives to T4 templates and EnvDTE for cross platform asp.net 5 development?

We currently use T4 templates to generate C# code files based on C# Code (Entity POCO's) and the EDMX (in older applications)
Moving to ASP.NET 5 with a view to support cross platform development, are there any code generation tools available that can read a projects class & meta data structures, and to generate C# files at design time, similar to T4 templates?
You can try Scripty - it is Roslyn based scripting.
Syntax highlighting for *.csx files works out of the box;
VS extension exists to process scripts on save;
MSBuild task exists to process scripts during buld process;
Script allows you to traverse a hierarchical model of the project;
Multiple files generation from single script is supported;
yeoman seems to be a good option. There exist some generators already for scaffolding asp.net 5 apps and you can create your own generators
It is cross platform and can be used on linux/mac/windows.
Even tt templates weren't supported earlier in asp.net-5 projects. It has been added recently (in Visual Studio 2015 Update 1).
The discussion is here: https://github.com/aspnet/Home/issues/272
And in the thread, Eilon said the Roslyn is the way to analyse the code and generate new ones... And he again said the ASP team has no immediate plan. So currently we have no solution from Microsoft.
But I did some search and didn't find any cross platform community tool to generate codes based on other codes. :(
Scriban worked for me as an alternative to replace T4 templates for generating unit test code. But it's a pure templating engine.
The new LeMP preprocessing engine for C# can be used as an alternative to T4 templates. May I ask what specifically you mean by "projects class & meta data structures"?
For this purpose I created a simple python
script called "autogen".
How it works: the script takes jinja template file (instead of T4) and data file (json) and generates one or multiple output files (e.g. C#, or any format) based on the template.
How it can be used (example): describe interface (methods, parameters) definition in json file, create *.j2 template files for C#, Java, Python, etc.. Then run autogen.py script and files for proxy/stub for all languages will be created.
This can help to create lot of similar code without copy/pasting and make code changes by simply changing single json file.
Moreover it can be integrated with build pipiline, msbuild (.net, .net core) and is cross-platform.
I have been looking into this same sort of thing, although not specifically with ASP.NET MVC but across project types as I move to .Net Core. I kept my T4 relying on EDMX early on. Which works out since EF7 moves beyond the file format in favor of code. Where I was planning on going with my code generation was a combination of ScriptCS and C# REPL. Roslyn complicates things for me a tad since there are no design time assemblies from what I understand. So the trick may be to understand and introspect cs files from within the project.

OpenText Reddot CMS Version Control

Does anyone know how you version / source control changes in Reddot Cms (OpenText). Also is there any best practice advice for release management of changes from one Reddot environment to another Reddot instance. Any help or advice would be greatly appreciated.
There is best-practice, but as you have probably realised, there aren't too many practitioners of RedDot these days. In case you should come back to this thread (or for someone else's benefit) Versioning is built into the Template Manager, but has to be enabled. There's no Source Control integration last time I checked, but we developed a prototype system that allows for the creation of templates in Visual Studio. The project to complete that has since died due to lack of commercial support, but some of the ideas may be useful for you if you want it.
I split up the answer in two parts: Versioning and migration between stages.
Versioning can only be done with the template history or via an external service that grabs the templates on a regular basis or triggered manually. At least for the Management Server there is no built-in service for a "real" versioning or release of more than just single templates/content classes or even including pages.
There are 3 ways of moving changes from dev to test or prod I have seen often:
Two templates: Using two templates on one server, on called "Development" and the other one "Production". All new development is done on the "Development" template and moved to the other template as soon as finished. If elements are different between those templates they need to be duplicated. This is typically on small installations without staging areas. Nowadays, you will find only very few of those.
Partial tree export: Development is done on a dev server and the changes are exported as partial tree. There is a special area in the project tree where pages are created which templates shall be moved over. These are exported including the templates and imported on the target server to override the existing ones.
Tool support: There are external tools for moving templates and content classes to other servers. There is e.g. SitePort (http://siteport.net , can also move whole templates between RedDot servers afaik) and the Sync Tool (http://www.erminas.de/en/products#synctool , can compare and move single element attributes and/or single lines of templates, please note: this shall not be advertisement as the tool is made by us but I do not know any other like this). Some companies also have custom development tools for this.

MVC 2 - Are Sattelite assemblies required for embedded resources? Embedded resources not working

Hello I have been working on an MVC 2.0 web application.
This has the requirement to switch between 2 languages.
The existing solution did not work well as the MVC [DisplayName] attributes and data annotation error messages etc did not work as they were not culture aware in MVC 2.0.
I followed the example here:
http://adamyan.blogspot.co.uk/2010/02/aspnet-mvc-2-localization-complete.html#!/2010/02/aspnet-mvc-2-localization-complete.html
With a few tweaks it is all working perfectly in my Visual studio Environment and switches language and uses the MVC diplay name etc fine now.
I am using embedded resources and have an English resx file (e.g MyPage.resx) and the culture version (e.g. MyPage.cy-GB.resx).
The problem is when I install this into a production environment it is not switching languages.
I am baffled since I thought these embedded resources would be part of the main web application dll so it should have no trouble finding the matching resource?
I know it is definitely changing the culture on the current thread. It just isn't loading the matching resource.
The application is installed using WIX without harvesting but I have included all files (aspx etc). Previously it was using a satellite assembly and creating a resource dll in the bin folder with the culture name. I removed this as I am just using embedded resources as mentioned. Is the satellite assembly a requirement for this? I am quite happy for them to be embedded.
I am really confused about how to resolve this so any advice would be very welcome.
Thanks
The MyPage.cy-GB.resx is embedded in the satellite assembly. It is necessary, in fact embedded resources are all that goes into satellite assemblies.