Home > Net >  Webapi how to receive the url parameter with a special symbol
Webapi how to receive the url parameter with a special symbol

Time:11-19

Encountered such a problem in the work, the other party need to provide a callback API interface on my side, but when the other parameters by value with [] symbols, don't know how to define the parameters in the c # webapi receives, for example:
Access url address: http://localhost:1373/ZrbApi/test? Data [api_appkey]=1001063
I don't know how to receive the data [api_appkey] this parameter,
Bosses genuflect is begged

CodePudding user response:

urlencode

CodePudding user response:

Encode,

CodePudding user response:

reference 1/f, mo zi Chen reply:
urlencode
can you detail, brother

CodePudding user response:

Try these JS function (variable (args) to parse the data parameter)

The function getQueryStrings () {
//the location. The search returned all content since the end of the question mark to the URL
Var qs=location. Search. Length & gt; 0? The location. The search. The substring (1) : "',

//save data array
Args={},

//each
The items=qs. Length & gt; 0? Qs. Split (& amp; "" ) : [],
The item=null,
Name=null,
Vaule=null,
I=0,
Len=items. Length;

//one by one, added to the array
For (var I=0; i The item=items [I]. The split ("=");
Name=decodeURIComponent (item [0]);
Value=https://bbs.csdn.net/topics/decodeURIComponent (item [1]);

If (name. Length) {
The args [name]=value;
}
}

Return the args.
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Copyright statement: this article to CSDN blogger (Billy - Chen) of the original article, follow the CC BY 4.0 - SA the copyright agreement, reproduced and this statement, please attach the original source link
The original link: https://blog.csdn.net/cbc12/article/details/85283489
  •  Tags:  
  • C#
  • Related