How to add a view from an external reference? - asp.net-mvc-5

I'm trying to load some views from an external dll. My problem is that I don't know how to do it. What I have for now is the dll added to my main aplication and
I already tried this:
services.Configure<RazorViewEngineOptions>(options =>
{
options.FileProviders.Add(embeddedFileProviderHeader);
});
but I saw this is only used for AspNet Core, what is a problem, because I'm using AspNet Mvc 5. So, is there something similar to RazorViewEngineOptions for AspNet Mvc 5?

Related

missing System.Web.Security in project

I am working on a web project with .Net core 3.1.
I need to use FormsAuthentication.SetAuthCookie in login action and when i add using System.Web.Security to project its unknown. I cant add this using.
I read all posts about but still wasn't able to solve this.
I studied many references and finally the result was nothing else this :
System.Web.Security only is available with .net framework and in core has no alternative or i couldn't find it.

Using a .NET class library in NodeJS app using Blazor

I have a .NET Standard project that includes a bunch of models and methods, and I want to use them in a NodeJS application written in TypeScript. All the samples I see for Blazor JavaScript interop integrate with JS through Razor files, but I couldn't find any samples that show how to integrate .NET code with NodeJS. Is this possible at all and if yes, how? Thanks!
This is not possible Client-side Blazor works only in browser and interop is only with browser JS, since it is browser who run WASM and JS inside themselves.
Previously you can theoretically integrate some NodeJS inside ASP.NET Core application using NodeServices, but they are would be obsolete in .NET Core 3. See https://github.com/aspnet/AspNetCore/issues/12890
If you want to run some code from Blazor inside NodeJS likely you have to create separate command line application and communicate between it and your NodeJS application.

System.TypeLoadException on Azure App Service

I'm running an asp.net 4.6 app on the app service. Just removed mvc from the site and using url rewrite to run an mvc free angular spa with a webapi.
Now it's asking for a type that was renamed months ago and works in pre mvc removal builds. I don't think it's got something to do with mvc though.
In trying to solve this I've xeroxed my local bin folder onto the server and the error still persists. So some sort of server config?
Has anyone ever experienced this before?
The error means that you are using a type which is not found in your assembly. To troubleshoot this issue, you need to find where you used this type. I suggest you use the Find in files feature provided by Visual Studio by pressing Ctrl+Shift+F. After found the place which used the type, you just need to delete it and rebuild your application.

ASP.NET Core dynamic assembly (dll) mvc (attribute) routing

I'm using the AssemblyLoaderContext in ASP.NET Core 1.1 to load a dll in my plugin folder in my MVC main application with the 'LoadAssemblyFromPath' function. However, I'd like to the attribute routing of my plugin dll's controller to work in my main application. For this I should be able to clear and rebuild the MVC routing. How is this possible to do? It used to be doable in MVC 4-5 using GlobalConfiguration, but as I read on some blogs, it was not a best practice and so the GlobalConfiguration is removed from ASP.NET Core.
So, how can I rebuild the MVC routes, not from the startup class, because I don't want to restart my web application?
I'm aiming for an experience like Wordpress and Drupal, where you upload the dll in this case to the server and in the UI, press activate to load this plugin.

Why would the RIAServices.EntityFramework NuGet Package break context class code generation?

I have an existing project using RIAServices with Entity Framework. The project builds correctly and generates the AmsiWeb.g.cs file with all the context classes for my services.
I am converting my designer based entities and ObjectContext with Code First entities and DbContext. I installed the RIAServices.EntityFramework NuGet package to the web application that contains my services. However, now when I build the AmsiWeb.g.cs file only contains the WebContext class. It doesn't contain any generated services.
I have only at this point converted a single EDMX model to Code First and DbContext and made the requisite changes to the services that use that model to inherit from DbDomainService.
I am using EF 5.0... not sure if that matters cause I'm not sure how adding a DLL to the AmsiWeb application project would break code generation.
What would cause this to no longer work and how can I fix it?
Maybe it's a problem within the msbuild task that generates the proxy code (I mean the *.g.cs file). Probably it's looking for the wrong version of a entity framework. Have a look at this blog post http://mcasamento.blogspot.it/2012/10/entity-framework-5-code-first-and-wcf.html in the final part I wrote an assembly redirect statement that did the trick
It turns out that their needs to be a redirect for Entity Framework 5.0 (4.4.0.0 since I was using .Net 4.0) in the web.config. But, since my RIA Services were in a web application project that was not my root project the code wasn't generating.
Once I added the redirect to the web.config of the web application with the RIA services in it, the context code was correctly generated.

Resources