我正在尝试构建我的C#项目,并且我收到错误消息"命名空间不直接包含诸如字段或方法之类的成员".它正在标记app.config文件的第一个字符(小于符号).
我已经检查了所有文件,找到了直接在命名空间内有变量或函数的地方 - 什么也没找到.app.config看起来很好.
谷歌让我失望了,我把头发拉了出来.可能导致此错误的原因是什么?
我正在阅读使用ASP.NET设计Evolvable Web API.在其中一个练习中,本书让我使用Visual Studio编辑Controller.这是在使用C#的ASP.NET中完成的.我使用的模板是标准的ASP.NET Web应用程序API.
我已经按照书中显示的方式编辑了控制器(虽然它似乎没有给出非常具体的指示).这是我的控制器的样子.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Http.ModelBinding;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OAuth;
using WebApplication4.Models;
using WebApplication4.Providers;
using WebApplication4.Results;
namespace WebApplication4.Controllers
{
public class GreetingController : ApiController
{
public string GetGreeting() {
return "Hello World!";
}
}
public static List<Greeting> _greetings = new List<Greeting>();
public HttpResponseMessage PostGreeting(Greeting …Run Code Online (Sandbox Code Playgroud)