首先在web.config中加上语句连接语句:
然后再控制器中测试
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using System.Web.Http.Cors;
using WebApplication.Models;
using System.Configuration;
namespace WebApplication.Controllers
{
public class ValuesController : ApiController
{
[EnableCors(origins: "*", headers: "*", methods: "*")]
// GET api/values
public IEnumerable Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
public Object Get(int id)
{
//return "