我无法连接到SQL Server,我的项目的连接字符串是:
<add name="Teleport_DEVEntities" connectionString="metadata=res://*/Data.Model.AdvertisingModel.csdl|res://*/Data.Model.AdvertisingModel.ssdl|res://*/Data.Model.AdvertisingModel.msl;provider=System.Data.SqlClient;provider connection string="data source=*****;initial catalog=****;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
不支持关键字:'元数据'
我该如何解决这个错误?
我在我的项目中使用webapi上传文件.我正在和邮递员一起测试.但是,Request.Content.IsMimeMultipartContent()始终返回false.
邮差截图:
FileUploadController代码:
public async Task<HttpResponseMessage> UserImageUpload()
{
try
{
if (!Request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
var userImageUploadPath = HttpContext.Current.Server.MapPath(CommonParameters.UserProfileImageServerPath);
var streamProvider = new CustomMultipartFormDataStreamProvider(userImageUploadPath);
await Request.Content.ReadAsMultipartAsync(streamProvider);
var files = new List<string>();
foreach (MultipartFileData file in streamProvider.FileData)
{
files.Add(Path.GetFileName(file.LocalFileName));
}
return Request.CreateResponse(HttpStatusCode.OK, files);
}
catch (Exception exception)
{
logger.ErrorFormat("An error occured in UserImageUpload() Method - Class:FileUploadController - Message:{0}", exception);
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
}
Run Code Online (Sandbox Code Playgroud) 我在项目中使用基于OAuth Bearer令牌的身份验证.成功登录请求后,我收到以下json.
{"access_token":"some token","token_type":"bearer","expires_in":1232}
Run Code Online (Sandbox Code Playgroud)
我想在json下面发送更多信息数据.我创建了身份验证票证并添加了authenticationproperties.但它并没有起作用.
GrantResourceOwnerCredentials方法代码:
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
try
{
context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
var schoolId = context.UserName;
var password = context.Password;
logger.InfoFormat(CommonConstants.LoginInfoLogMessageFormat, schoolId);
var loginOperator = new LoginManager();
var result = loginOperator.IsUser(schoolId, password);
if (result)
{
var identity = new ClaimsIdentity(context.Options.AuthenticationType);
identity.AddClaim(new Claim("sub", context.UserName));
identity.AddClaim(new Claim("role", "user"));
var authenticationProperties = GetUserAuthenticationProperties();
var authenticationTicket = new AuthenticationTicket(identity, authenticationProperties);
context.Validated(authenticationTicket);
}
else
{
context.SetError("invalid_grant", "Kullan?c? ad? veya ?ifre yanl??.");
}
}
catch (Exception exception)
{ …Run Code Online (Sandbox Code Playgroud)