0

Can I use Aurelia also without the ASP.NET Core Framework, but just with ASP.NET, because the Backend is written completely in .NET Framework 4.5 and the ASP.NET Core App does always throw exceptions on static Calls, Type-Loading, and so on.

Is there a way to set up Aurelia on Standard.NET Framework? Or is there a way which makes it possible to call the .NET Framework Logic without Exceptions?

I've already tried to install the "Microsoft.NETCore.Portable.Compatibility" Nuget-Package, which resolved some of my in the Aurelia Code directly, but the backend still throws exceptions. Could it be possible that the backend code needs to be in the wwwroot directory of the Aurelia App? (as .dll or something), may that be the reason why it is not working?

SynozeN Technologies
  • 1,291
  • 1
  • 12
  • 19
  • 1
    Aurelia is a client side Javascript framework, which backend that you are using is irrelevant. – DavidG May 22 '17 at 10:41
  • Oh yes. You are right. The problem is, that I am not able to set up an ASP.NET MVC Application (Without .NET CORE) with Aurelia enabled. All generators and Instructions only handle .NET Core ASP.NET which is no possibility for me. Do you have any idea or instruction how I can achieve this? – Thomas Stockinger May 22 '17 at 12:44
  • using the Aurelia cli once it was installed you can do `au new` it create the default necessary folders/files needed pretty damn neat imo. this is a npm command btw... only really need node.js installed. http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/the-aurelia-cli – mvermef May 22 '17 at 17:25
  • I just found it easier and cleaner to just separate the client code from the api server code. One folder for each. Client runs on Static File Server that serves up the html/js and the webapi server runs ona different port and serves up the web api requests. – Mike May 25 '17 at 17:23

1 Answers1

0

I think what you need is a .Net Core project that runs on the .Net Framework 4.5.2. Then you can communicate from this website project to a backend dlls also written using .Net Framework 4.5.2.

To set up the a new Aurelia .Net Core project you can follow the instructions Rob Eisenberg gives in https://channel9.msdn.com/Events/Build/2017/T6032. See the slide at 8:39 in.

To quote from this slide:

dotnet new --install Microsoft.AspNetCore.SpaTemplates::*

Install Node.js from https://nodejs.org

To create a new projects (from cmd)

  • mkdir app-folder-name-here
  • cd app-folder-name-here
  • dotnet new aurelia
  • dotnet restore
  • npm install
  • export ASPNETCORE_ENVIRONMENT=Development
  • dotnet run

This will create a new .Net Core project that runs on the .Net Core Framework. In this you can see an example where the Aurelia viewmodel uses HttpClient to fetch data from a function in an MVC controller. However from this controller you won't be able to reference and interact with dlls written in Framework 4.5.2 because this project is initially generated to use the .Net Core framework.

To get around this you need to convert the project over to use the .Net Framework 4.5.2 manually. You can do this following the instructions here:

How to change target framework with VS 2017 RC?

Except where it says to include the following into the csproj file

<TargetFramework>net462</TargetFramework> <RuntimeIdentifier>win7-x86</RuntimeIdentifier>

Make sure you put the target framework as net452

I went through the above steps and it all worked for me. Note I am using VS 2017. I'm not sure if there is anything in the above link that is VS 2017 specific.

PRS
  • 667
  • 7
  • 22