asp.net调用前台js调用后台代码分享 C#前台js调用后台代码前台js<script type="text/javascript" language="javascript"> function Ceshi() { var a = "<%=Getstr()%>"; alert(a); }</script><input type="button" onclick="Ces
先说下需求:在原来的WebApi项目中增加对js跨域的请求支持,请求方式:以POST为主,webapi路由规则根据原项目需求修改如下: public static void Register(HttpConfiguration config) { // Web API configuration and services // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "De
C#前台js调用后台代码前台js<script type="text/javascript" language="javascript"> function Ceshi() { var a = "<%=Getstr()%>"; alert(a); }</script><input type="button" onclick="Ceshi();" value=&quo