将变量从angular传递到c#web api

问题描述 投票:0回答:2

我具有带有post函数的发送变量

  someFunction(param) {
    console.log("someFunction> "+param);
       return this.http.post(appSettings.BackEndUrl + '/test/someFunc',param);     
    }

console.log显示

someFunction> 10

在后端,我有

public async Task<Object> someFunc(string ttt)
{
    WriteLog("someFunc.txt", "start > "+ttt);

我在日志中看到

开始>

即使我将字符串更改为int

public async Task<Object> someFunc(int ttt)
{
    WriteLog("someFunc.txt", "start > "+ttt);

我仍然只能看到

开始> 0

我该如何解决?

c# angular post transfer
2个回答
1
投票

尝试将其添加为查询字符串更改此方式:

someFunction(param) {
console.log("someFunction> "+param);
   return this.http.post(appSettings.BackEndUrl + '/test/someFunc?ttt='+param);     
}

0
投票

您可以对对象{ ttt: param }使用发送参数

 someFunction(param) {
    console.log("someFunction> "+param);
       return this.http.post(appSettings.BackEndUrl + '/test/someFunc',{ ttt: param });     
    }
© www.soinside.com 2019 - 2024. All rights reserved.