从ASP调用后端.net dll.. NET Web api

本文关键字:NET Web api dll net ASP 调用 后端 | 更新日期: 2023-09-27 18:03:25

我正在构建客户端服务器应用程序。

业务逻辑是用c++/CLI构建的。在同一个溶液中,我有ASP。. NET Web api项目。

对于登录,我在后端有方法。对于登录,我需要这样做

using Back_End;
public IHttpActionResult Logon([FromBody]Logon_Request model)
{
 string Answer = Back_End.Logon(model.Name, model.Password);
}

Back_End在相同的解决方案中位于dll内部。

当我尝试调用api/logon时,它返回一个异常。

{
"Message": "An error has occurred.",
"ExceptionMessage": "Could not load file or assembly 'Back_End, Version=1.0.5676.23091, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)",
"ExceptionType": "System.IO.FileLoadException",
"StackTrace": ".........."
}

当然,因为它不在IIS服务器上。

最后我的问题:

-但是我需要在服务器上部署所有的业务逻辑dll吗?

-乳清在这里起作用吗?

-有"更好"的方法来做我想做的吗?

-也许我需要把它作为一项服务来使用并打电话?但它将是API的API

从ASP调用后端.net dll.. NET Web api

Web。配置文件

<compilation debug="true" targetFramework="yourTargetFramework">
      <assemblies>
        <add assembly="yourAssemblyName, Version=yourAssemblyVersion, Culture=neutral, PublicKeyToken=yourPublicKeyToken" />
      </assemblies>
</compilation>

登录。aspx页

<%@ Register Assembly="yourAssemblyName, Version=yourAssemblyVersion, Culture=neutral, PublicKeyToken=yourPublicKeyToken" Namespace=".dll Namespace" TagPrefix="name to call the loginUserControl" %>

交货。

...TagPrefix="rs" %>

<rs:Login/>