我正在使用dotnet core 2.1中的角度SPA应用程序的"新"项目模板,如文章中所述使用Angular项目模板和ASP.NET Core.
但是这篇文章没有提到保护SPA本身的任何内容.我找到的所有信息都是关于保护WEBAPI,但首先我对保护SPA感兴趣.
这意味着:当我打开我的SPA时,例如https:// localhost:44329 /我希望立即重定向到授权服务器,而不是单击某个将执行身份验证的按钮.
背景:
当前的方法是实施需要经过身份验证的用户的MVC策略.但这只能应用于MVC控制器.这就是我添加HomeController以满足第一个请求的原因.
见项目结构:
我的Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = "CustomScheme";
})
.AddCookie()
.AddOAuth("CustomScheme", options =>
{
// Removed for brevity
});
services.AddMvc(config =>
{
// Require a authenticated user
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
config.Filters.Add(new AuthorizeFilter(policy));
});
// In production, the …Run Code Online (Sandbox Code Playgroud) 我有这个搜索框:

搜索框的代码是:
<form method = "post" action="search.php" class = "pull-down navbar-search">
<div class="input-append">
<input class="search-query input-medium" name="search_query" type="text" placeholder="Arama Yap" >
<button type = "submit "class="btn btn-large" type="button"><i class="icon-search"></i></button>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
我希望搜索框在框和按钮之间没有空格.我怎么能完成它?谢谢.
我有三个单选按钮,我的字段值类型是整数,如Maintenance for 3,Active for 1和Inactive for 2.
@Html.RadioButtonFor(model => model.StatusId, "3") Maintenance
@if (Model.IsReady == true)
{
<span> @Html.RadioButtonFor(model => model.StatusId,"1") Active</span>
}
@Html.RadioButtonFor(model => model.StatusId, "2") Inactive
Run Code Online (Sandbox Code Playgroud)
我使用上面的代码,然后正确插入数据,但当我的表单在编辑模式下打开,然后我没有选择任何单选按钮.
我也使用下面的代码,但没有成功.
@Html.RadioButtonFor(model => model.StatusId, "3", Model.StatusId == '3' ? new {Checked = "checked"} : null) Maintenance
@if (Model.IsReady == true)
{
<span> @Html.RadioButtonFor(model => model.StatusId, "1",Model.StatusId == '1' ? new {Checked = "checked"} : null) Active</span>
}
@Html.RadioButtonFor(model => model.StatusId, "2",Model.StatusId == '2' ? new {Checked = "checked"} : …Run Code Online (Sandbox Code Playgroud) 关于理解使用哪个redis数据库以及如何配置它的问题.
我有一个默认的ASP.NET核心Web应用程序和一个默认配置的本地redis-server(包含15个数据库)
在包管理控制台上我安装了:
Install-Package Microsoft.Extensions.Caching.Redis
Run Code Online (Sandbox Code Playgroud)
Redis在Startup.cs中配置如下:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddDistributedRedisCache(option =>
{
option.Configuration = "127.0.0.1";
option.InstanceName = "master";
});
}
Run Code Online (Sandbox Code Playgroud)
读取和写入缓存中的值的代码取自文档:
var cacheKey = "TheTime";
var existingTime = _distributedCache.GetString(cacheKey);
if (!string.IsNullOrEmpty(existingTime))
{
return "Fetched from cache : " + existingTime;
}
else
{
existingTime = DateTime.UtcNow.ToString();
_distributedCache.SetString(cacheKey, existingTime);
return "Added to cache : " + existingTime;
}
Run Code Online (Sandbox Code Playgroud)
但是这个代码只使用默认数据库db0,无论我配置什么.
例如,使用此配置:
services.AddDistributedRedisCache(option =>
{
option.Configuration = "127.0.0.1";
option.InstanceName = "db6";
}); …Run Code Online (Sandbox Code Playgroud) 今天,我们在Azure门户中遇到了以下消息
如果配置了部署表单源控件,则无法从门户网站添加WebJob。
我们假定这是一个新功能,因此拼写不正确:“部署表单源代码控制”应为“ 来自源代码控制的部署”。
我不知道在哪里设置可以解决此问题的设置。
它必须在我们假设的DevOps中。
当我打开一个项目时,它失败了
有人有解决方案吗?
我试过这些步骤:
观察:
我想开发一个vsts扩展。
开发周期的描述过程是:
这对我来说有点麻烦,因为它需要大量时间来测试开发。
有什么办法可以加快开发周期?
有什么方法可以模拟TFS?
这是我对页面的初始加载:
在改变一些文本后,HMR会被激活,但是附加 DOM而不是替换它:
有没有人知道什么可能导致这个问题?控制台上没有错误.
更新:
我在命令行中使用了带有角度模板的ASP.NET Core.此模板使用bootstrap和jquery.我想删除这两个组件,因此我想使用材料
我们在本地TFS 2018 RC2 RTW 中使用git
当我们检查我们的代码时,我们通过添加哈希和数字来协助工作项,例如#8635
在文档中写道,这应该与pull-requests一起使用.但在我们的例子中,我们并不需要拉取请求.
是否可以在没有拉取请求的情况下将提交与工作项链接?
有关:
更新:
我刚刚在同一团队项目的不同git项目上测试了这个.
猜猜看:它按预期工作.奇怪的是,这个git项目需要有些东西......
我对这个html/css完全不熟悉我试图将带有背景的文本浮动为图像.是的我做了但是问题是文本浮动在图像上.如果使用margin-top来调整图像,它只是简单地拉下整个div.Here down我给了我想要的图形表示.
HTML
<div class="maincon">
<div class="picon" style="background-image: linear-gradient(to bottom, rgba(0, 0, 0, .02), rgba(0, 0, 0, .8)), url('img/apple.jpg') "><p>Hi</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.maincon {
margin-top: 95px;
width: 80%;
margin-left: auto;
margin-right: auto;
height: 100%;
}
.picon {
width: 100%;
height: 80%;
background: none center/cover #f2f2f2;
}
.picon p {
}
Run Code Online (Sandbox Code Playgroud) azure-devops ×3
c# ×3
angular ×2
.net ×1
.net-core ×1
asp.net ×1
asp.net-core ×1
azure ×1
caching ×1
css ×1
deployment ×1
git ×1
html ×1
redis ×1
search-box ×1
tfs ×1
webpack ×1
webpack-hmr ×1