自从我使用ASP.NET 5以来已经有一段时间了,所以我很惊讶,现在默认将bower组件放在wwwroot\lib文件夹中.这是因为.bowerrc文件:
{
"directory": "wwwroot/lib"
}
Run Code Online (Sandbox Code Playgroud)
在早期版本中,bower组件存储在./bower_components文件夹中,这对我来说仍然更有意义.
我希望我需要一个gulp/grunt(使用wiredep)任务来构建并将我的JavaScript和CSS文件复制到wwwroot文件夹中.
很明显我错过了一些东西,但我无法理解它或找到关于此事的任何合适的信息.
为什么我需要在`wwwroot\lib'文件夹中的所有bower组件(包括源代码),特别是在部署时,以及部署我的Asp.NET 5 Web应用程序所需的工作流程是什么?
我们通过以下方式使用RavenDb进行mvc3应用程序设置(在NoSql的帮助下使用RavenDb和Asp.net MVC):
以下代码位于Global.asax中
private const string RavenSessionKey = "RavenMVC.Session";
private static DocumentStore documentStore;
protected void Application_Start()
{
//Create a DocumentStore in Application_Start
//DocumentStore should be created once per
//application and stored as a singleton.
documentStore = new DocumentStore { Url = "http://localhost:8080/" };
documentStore.Initialise();
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
//DI using Unity 2.0
ConfigureUnity();
}
public MvcApplication()
{
//Create a DocumentSession on BeginRequest
//create a document session for every unit of work
BeginRequest += (sender, args) =>
{
HttpContext.Current.Items[RavenSessionKey] = documentStore.OpenSession(); …Run Code Online (Sandbox Code Playgroud) 正如.NET开发人员目前我们RavenDb在nosql场景中使用的那样是我们的默认数据库选择.现在微软推出DocumentDb了一个nosql文档数据库即服务,我们正在寻找两者之间的差异.数据库即服务看起来不错,因为我们在自己的服务器上运行RavenDb.
Ayende Rahien作为一个有趣的帖子,但它与旧DocumentDb版本相比有点过时了.尽管如此,它仍然是一个很好的阅读.
编辑:看完后在Azure上DocumentDB思考,我开始怀疑关于定价的DocumentDb.假设我的数据模型包含7个集合,这意味着我必须每月支付7*25 美元 = 175美元!我必须在这里犯一些错误,对吧!?
Edit2: DocumentDb创建者的想法似乎将多种类型的文档放入一个集合中,这对我来说在使用ravendb一段时间后似乎有点奇怪.该术语在collection理解DocumentDb定价时遇到了一些麻烦,因为它在DocumentDb当时完全不同RavenDb
在这情况下,你会选择DocumentDb过RavenDb?
我有一个带有Add方法的存储库,该方法将IEnumerable作为参数:
public void Add<T>(T item) where T : class, new(){}
Run Code Online (Sandbox Code Playgroud)
在单元测试中,我想验证是否使用IEnumerable调用此方法,该IEnumerable包含与另一个IEnumerable完全相同的元素数量
[Test]
public void InvoicesAreGeneratedForAllStudents()
{
var students = StudentStub.GetStudents();
session.Setup(x => x.All<Student>()).Returns(students.AsQueryable());
service.GenerateInvoices(Payments.Jaar, DateTime.Now);
session.Verify(x => x.Add(It.Is<IEnumerable<Invoice>>(
invoices => invoices.Count() == students.Count())));
}
Run Code Online (Sandbox Code Playgroud)
单元测试结果:
Moq.MockException :
Expected invocation on the mock at least once, but was never performed:
x => x.Add<Invoice>(It.Is<IEnumerable`1>(i => i.Count<Invoice>() == 10))
No setups configured.
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
拿这个夹具我想checkoutId根据before夹具钩子中API 调用的结果来设置,这样我就可以用它来设置我的测试页面
let checkoutId;
fixture`Check out as guest user`
.page`localhost:3001/checkout/start/${checkoutId}`
.before(async () => {
await checkout.getCheckoutId(sampleData.cart)
.then(id => (checkoutId = id));
});
// and here the rest of my tests based on the page
Run Code Online (Sandbox Code Playgroud)
我尝试了fixture hooks,共享变量,但我无法让它工作,请求页面时 checkoutId 未定义。
这种情况甚至可能吗?
testing automated-tests browser-automation e2e-testing testcafe
作为MassTransit和RabbitMQ的新用户,我目前正在尝试使ASP.NET核心服务与MassTransit一起使用。
采取本文档部分来配置MassTransit和ASP.NET Core,我无法使其正常运行。
当前(部分)Startup.cs看起来像
services.AddMassTransit(x =>
{
x.AddConsumer<MailConsumer>();
x.AddConsumer<MailFailedConsumer>();
x.AddBus(provider => ConfigureBus(provider, rabbitMqConfigurations));
});
private IBusControl ConfigureBus(
IServiceProvider provider,
RabbitMqConfigSection rabbitMqConfigurations) => Bus.Factory.CreateUsingRabbitMq(
cfg =>
{
var host = cfg.Host(
rabbitMqConfigurations.Host,
"/",
hst =>
{
hst.Username(rabbitMqConfigurations.Username);
hst.Password(rabbitMqConfigurations.Password);
});
cfg.ReceiveEndpoint(host, $"{typeof(MailSent).Namespace}.{typeof(MailSent).Name}", endpoint =>
{
endpoint.Consumer<MailConsumer>(provider);
});
cfg.ReceiveEndpoint(host, $"{typeof(MailSentFailed).Namespace}.{typeof(MailSentFailed).Name}", endpoint =>
{
endpoint.Consumer<MailFailedConsumer>(provider);
});
});
Run Code Online (Sandbox Code Playgroud)
该交换在启动时在RabbitMQ中自动创建,但是没有队列绑定到我期望的交换。
调用我的API端点后,我可以看到交换上的活动,但是由于没有队列,因此消费者当然不执行任何操作。
我缺少什么(明显)部分?
我在解决404错误时遇到了麻烦:
Global.asax.cs中的默认路由:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
VideoController.cs:
[HttpPost]
public ActionResult Save(int id)
{
try
{
return Json(new
{
ID = "0"
});
}
catch
{
return new HttpStatusCodeResult(418, "I'm a teapot");
}
}
Run Code Online (Sandbox Code Playgroud)
在我看来,Action.cshtml中的ActionLink:
@Ajax.ActionLink("GoSave", "Save", "Video", new { id = 1 },
new AjaxOptions { OnFailure = "Error", OnSuccess = "Saved",
HttpMethod = "POST" })
Run Code Online (Sandbox Code Playgroud)
actionlink的url按预期呈现:/ Video/Save/1
当我点击链接时,我得到了404.
我没看到什么?
目前,我们正在建立一个网上商店作为SPA应用程序。所有SKU信息均由Web Api 2服务提供。
当然,网上商店对所有访问者都是公开可用的,并且目前只有一个用户可以登录来管理网上商店:管理员。
对于管理员,我们使用bearer令牌内置了基本身份验证,就像Internet上的许多示例向我们展示的那样,但是现在我们需要每个用户登录后才能看到任何产品。并不是我们真正想要的网上商店;-)
我们想要实现的是我们的Web Api不适用于世界,而仅适用于我们的SPA应用程序。关于授权的每篇博客文章或教程似乎都假定总是有一个用户需要登录,在我们的例子中,只有一个用户:管理员。
该AllowAnonymous属性使特定的API调用再次可用于世界,因此这也是死胡同。
基本上,它可以防止其他任何应用程序(网络或移动应用程序)从我们的Web Api中获取数据。
在没有让我们的网上商店的匿名访问者登录的情况下,保护我们的Web Api的最佳和最安全的方法是什么?
目前的解决方案:尽管我对这种解决方案并不满意,但它现在仍然可以使用。我们为特定域启用了CORS,从而实现了OAuth隐式流程。
security authorization single-page-application asp.net-mvc-5 asp.net-web-api2
c# ×2
ravendb ×2
.net ×1
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
bower ×1
c#-4.0 ×1
e2e-testing ×1
gulp ×1
masstransit ×1
moq ×1
multi-tenant ×1
rabbitmq ×1
routing ×1
security ×1
testcafe ×1
testing ×1
unit-testing ×1
verify ×1