Sometimes write locallyCodeWhich has many judgments. Or what is the direct transfer of parameters?
You need to use the local environment. If it is not a local environment, access is normal. In the local environment, data is directly returned.
In the past, 127.0.0.1 or others were directly judged.
Now:
Httprequest. islocal can be implemented
Whether it is localhost or IIS 127.0.0.3ip access. Whether to directly bind the host to the domain name asd.com for access can be determined normally
First, add an extension method.
Public Static Class Httprequestmessageextensions { Public Static Bool Islocal ( This Httprequestmessage request ){ VaR Localflag = request. properties [ " Ms_islocal " ] As Lazy < Bool > ; Return Localflag! = Null && Localflag. Value ;}}
Use
// Get API/Values Public Ienumerable < String > Get (){ If (! Request. islocal ()){ Return New String [] { " Value1 " , " Value2 " };} Else { Return New String [] { " Value1 " };}}
Very convenient.