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.
Related
I'm very new to NodeJs/expressJs, i read tons of articles on internet and still don't understand it
is NodeJs a web server like IIS ? if so can i host an asp.net app in NodeJS ?
Is expressJs a framework like ASP.NET ?
I currently work on both IIS ASP.NET applications as well as NodeJS/ExpressJS systems and the below is what I have noted to be different:
IIS:
Windows server based
Can have strict setups such as MVC etc
Built in deployment that compiles the entire website
Setup can take quite some time to create all modals and get all
plugins working etc
Services can take some time setup and modal mapping can be tedious
NodeJS/ExpressJS:
Not Windows based. I run this typically on an Ubuntu server with
Nginx to push the domain to the public
Easy to setup and fast to get something basic online
Does not natively compile and runs files as they are
Uses npm package manager with easy to install packages
Does not have strict setups but you can technically create your own
MVC style system
Code can quickly become messy however with the correct approach you
can manage the amount of code easily.
NodeJS is not a web server. It is a backend server (Such as a REST API etc)
ExpressJS sits ontop of NodeJS to add functionality and is essentially a framework. Coupled with jade/pug you can write js inside the html.
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.
I have made a ServiceStack Web App that uses a custom AppHost from a plugin (similar to the example https://github.com/NetCoreWebApps/WebApp/tree/master/src/apps/chat). I can run it on macOS with the dotnet command as per the examples.
Can I host my Service Stack Web App on IIS? What approach should I take? Reverse-proxying Kestrel like this https://learn.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x
or will I need to have different AppHost/Startup code for the two hosting situations?
Or maybe there's a fundamental reason why it will never work?
WebApp is a standard .NET Core 2.0 App so you'll be able to host it as you would any other .NET Core App. Normally reverse proxies don't require anything except the internal url where the request is proxied to, but it looks like IIS wants you to explicitly call .UseIISIntegration() which is an issue that may have prevented the existing WebApp binary as it didn't call .NET Core 2.0 WebHost.CreateDefaultBuilder(args) which among other things would turn on IISIntegration when the .NET Core App is hosted in IIS/Windows which is now being done from this commit.
You can find the updated Web App binaries with this change in the /web folder of the https://github.com/NetCoreWebApps/Chat project.
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.
I was going to try Subsonic, you can generate DAL with buildProvider element in an ASP.NET website project. But I get curious why Web applications or windows applications do not support BuildProvider.
PS: I know for Subsonic there is one other option to use it with other than BuildProvider, but I just get curious.
It doesn't work because of the different way things are compiled in web application projects vs. website projects. From what I read on MSDN, it has to do with the fact that in web app projects, all your code files are compiled into a single assembly using MSBuild before deployment, but Build Providers are used to generate code that is compiled at runtime (from your App_Code folder).
In website projects, all of your code is compiled at runtime so it all plays nicely together.
You could possibly hook it into your pre-build event, and call the sonic.exe with the proper command line.