using (IDbConnection dbConnection = openConnection)
{
string uQuery = "INSERT INTO User (Email, UserName, Password)"
+ " VALUES(@Email, @UserName, @Password)";
dbConnection.Open();
dbConnection.Execute(uQuery, User);
}
Run Code Online (Sandbox Code Playgroud)
我收到一个sql异常:关键字'User'附近的语法不正确.在db.Connection.Execute语句上.即使我省略了语句的User参数,我也会得到相同的错误.我插错了吗?
我正在运行一个 ASP.NET Core 2.0 应用程序,该应用程序利用应用程序网关后面的 Azure 应用服务中托管的 ASP.NET Identity。
我设置了一个自定义域,通过 SSL 指向应用程序网关,然后终止 SSL 并将请求转发到我的后端池,该池使用超过 80 的默认 *.azurewebsites.net 域。
例如,请求 custom.com:443 ---> 应用程序网关 ---> custom.azurewebsites.net:80
我已使用以下中间件将 ASP.NET Core 2.0 应用程序配置为在 1 小时后将用户会话超时:
services.ConfigureApplicationCookie(options =>
{
options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
});
Run Code Online (Sandbox Code Playgroud)
当用户超时然后执行另一个操作时,他们将被重定向到 custom.azurewebsites.net:80 上应用服务的登录页面,而不是通过应用程序网关返回。
有没有一种方法可以在超时时重定向到绝对 URL 而不是相对 URL?
在 .NET Core 上,使用System.Net.Http.HttpClient,先调用response.Content.ReadAsStringAsync(),然后调用是否安全response.Content.ReadAsStreamAsync()?
例如,做这样的事情。
var response = await client.GetAsync("http://example.com");
var respStr = await response.Content.ReadAsStringAsync();
// ... Do something with the string
var respStream = await response.Content.ReadAsStreamAsync();
// ... Do something with the stream
Run Code Online (Sandbox Code Playgroud)
我担心响应内容会被传输,因此无法阅读两次。
我已经用几个请求对其进行了测试,它总是对我有用,但它能保证有效吗?
我有一个带有 ASP.NET Core 的 API,它将由本机移动应用程序(当前是 UWP、Android)使用,我正在尝试实现一种客户端可以使用用户名/密码和外部提供商(例如谷歌和脸书。现在我正在使用openIddict并且我ExternalProviderCallback必须返回本地令牌,我假设当前返回cookie!(我已经从某处复制了大部分代码)而且它似乎不是我认为正确的方法的 AuthorizationCodeFlow !
现在这是我的启动课程
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
if (env.IsDevelopment())
{
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IConfiguration>(c => Configuration);
services.AddEntityFramework();
services.AddIdentity<ApplicationUser, IdentityRole>(config => …Run Code Online (Sandbox Code Playgroud) authentication google-authentication oauth-2.0 asp.net-core openiddict
我在Mac OS X上的.NET Core中创建了一个新的.NET类库项目.在项目构建期间,我想将文件复制到调试目录中.如何将其添加到.csproj文件中?
.NET Command Line Tools (1.0.1)
Product Information:
Version: 1.0.1
Commit SHA-1 hash: 005db40cd1
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/1.0.1
Run Code Online (Sandbox Code Playgroud) 我正在创建一个准系统.NET Core web api项目(从下面的空白模板开始)https://andrewlock.net/removing-the-mvc-razor-dependencies-from-the-web-api-template-in-asp-网核心/
下面的代码工作正常,直到我添加了StructureMap.现在,我收到了这个错误.
StructureMap.StructureMapConfigurationException:没有注册默认实例,无法自动确定类型'System.IServiceProvider'
没有为System.IServiceProvider指定配置
1.)Container.GetInstance()
在StructureMap.SessionCache.GetDefault(Type pluginType,IPipelineGraph pipelineGraph),位于WebApplication4.Startup.ConfigureServices(IServiceCollection服务)上的StructureMap.Container.GetInstanceT ---从抛出异常的上一个位置开始的堆栈跟踪---在System.Runtime Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()中的Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()中的Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)上的.ExceptionServices.ExceptionDispatchInfo.Throw()
有任何想法吗?
请注意:我们没有使用,builder.AppMvc()因为我们正试图尽可能减少这个api.
这是相关的代码.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
var builder = services.AddMvcCore();
builder.AddApiExplorer();
builder.AddAuthorization();
builder.AddFormatterMappings();
builder.AddJsonFormatters();
builder.AddCors();
// Register the Swagger generator, defining one or more Swagger documents
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
});
var container = ContainerConfigurator.Configure();
return container.GetInstance<IServiceProvider>();
}
// This method gets called by the runtime. Use this method to …Run Code Online (Sandbox Code Playgroud) .net-core ×3
asp.net-core ×3
c# ×3
.net ×1
azure ×1
csproj ×1
dapper ×1
macos ×1
oauth-2.0 ×1
openiddict ×1
sql ×1
structuremap ×1